How to resize and float right a background image using css?
Tags: html,css
Problem :
I am working on this site: http://www.problemio.com and I have a requirement to add the background image to the top banner which I did.
What I can't figure out how to do is how to shift it all the way to the right and make it smaller in length so that it only takes up half of the screen width.
Any idea how to do that? So far I have this css for the overall banner div:
.banner
{
width:60em;
margin: 0 auto;
position: relative;
padding: 0.3em 0;
z-index: 1;
background-image: url('http://www.problemio.com/img/ui/problemiotoprightimage.png');
background-repeat: no-repeat;
background-image: right-align
}
but I don't know how to make the background image align right and rescale to be 50% of the entire width of the div. Any ideas?
Thanks!
Solution :
You can use left
, right
, bottom
, top
and center
for aligning backgrounds. Also percentages.
background: url('http://www.problemio.com/img/ui/problemiotoprightimage.png') right no-repeat;
However, you cannot resize the images using CSS2 but in CSS3.
background-size: <width> <height>;
More usage:
background: url('http://www.problemio.com/img/ui/problemiotoprightimage.png') top right no-repeat;
To align bottom and centered:
background: url('http://www.problemio.com/img/ui/problemiotoprightimage.png') bottom center no-repeat;
CSS Howto..
Here's a responsive CSS solution using flex function addButtonClickHandler() { alert('Add button clicked!'); } function deviceClickHandler() { alert('Device clicked!'); } var addButtons = document.querySelectorAll('.add'); var devices = document.querySelectorAll('.device'); addButtons.forEach(function(addButton) {...
This may be what you are looking: Bootsnipp Responsive Carousel In case the link dies: http://bootsnipp.com/snippets/featured/responsive-bs-carousel-with-hero-headers it can be found searching www.bootsnipp.com for "Carousel". The important aspects are located in...
If you give the first li of each new row a class with the CSS of "clear:both", it should work. Check this out and see if it's what you're looking...
Found the fix... As I said, trying to force the container to refresh its content using some different css properties didn't work. What worked though was to add a span...
It's possible using the \A escape sequence in the psuedo-element generated content. Read more in the CSS2 spec. #restart:before { content: '\A'; } You may also need to add white-space:pre;...
I think background images are your only real pure-CSS option, since content isn't well-supported (or supported at all) on earlier browsers. If you're okay with it not being a pure...
php is not sending the appropriate content type header in the response. for you add these line s to the top of the page <?php header("Content-type: text/css"); ?> <?php header("Content-type:...
First of all, you use the same id in 6 elements for every movie, which you shouldn't. An id is unique, so change that to like 'descriptive_div_1', 'descriptive_caret_1', etc (I...
Use three tween points in your keyframes declaration, and remove the alternate keyword. The non-alternate version of your original keyframes declaration would be: @-webkit-keyframes line-animation { 0% { -- start...
The thing you have to keep in mind is that the opacity property will affect the opacity of the entire element, including its text/children. If you want to affect JUST...
your sidebar has position absolute and bottom:35px. so no matter how big (or small) the screen is - it will be on 35px from bottom. other than that - i...
You have some way to do this. You can add a (for example span) in your a tag. <li> <a href="#"> <span class="icon icon-page1"></span> Page 1 </a> </li> and do...
You have to use div that covers over the text area so that you can select image and submit form as multipart. Its totally game of CSS. You can use...
The problem is with the Dynamic type. I converted the ViewBag.SiteName to String first before inserting it and it worked....
Use the <col> tag and style it following this guide. This way you only need to add a class (or inline style specification) to the <col> element instead of each...
My comment above so to clarify why both snippets are completely posted here. "Dude your code is working. The problem is that the hierarchy is working exactly like it is...
Here is a basic submenu setup: http://jsfiddle.net/Wss5A/ * { list-style:none; margin:0; padding:0; font-size:1em; cursor:pointer; } #menu{ margin:3px; } #menu > li{ /* Top Level */ float:left; margin-right:3px; } #menu >...
You could set the vertical-align: middle; to the inline elements and remove useless top/bottom margin from your Enter Domain Name input. .elegantaero input[type="text"], .elegantaero select, .elegantaero .button { vertical-align: middle;...
The easiest way is to get the current controller and action from the ViewContext's RouteData. Note the change in signature and use of @ to escape the keyword. <% var...
You can use Javascript to change the innerHTML of elements. For example, create a div and give it the ID "myDiv": <div id="myDiv"></div> Then, when the user clicks on a...
You need to use JavaScript: var d = document.getElementById("button"); d.addEventListener('click',function(){ d.className = d.className + " move"; }); Demo: http://jsfiddle.net/LJHQW/3/ Or, if you're already using jQuery: $('.button').click(function(){ $(this).addClass('move'); }); Demo: http://jsfiddle.net/LJHQW/1/...
write this in your css h3, p{ margin:0; } ...
Old way: Use a table with 1 row (tr) and 3 cells (td), put your DIVs in those cells, make sure the cells are valign=top. People that shun table layout...
this is how is done, step-by-step: http://css-tricks.com/row-and-column-highlighting/
As you mentioned, you need to check your sourcemap file to determine the original SCSS files. Then you need to setup 2 grunt tasks (or you can use Gulp): build...
Try: HTML: <div class="container"> <div class="table"> <div class="visible"> <p>image</p> </div> <div class="collapse"> <p>Text</p> </div> </div> </div> CSS: .table { display:table; width:80%; margin:0 auto; } .visible, .collapse { display:table-cell; }...
If I understand well your question, you want to know if it is possible to include HTML content into a TEXTAREA element. That is not possible, but you can look...
It's easy, but it's CSS3 and not supported on old browsers. Use background-size:cover or background-size:contain in your CSS. CSS-tricks has an article with other, more robust solutions....
You can use the :not() pseudo-class: button.current:not(.inactive) { background-color: #000; } button:hover:not(.inactive) { background: #0007d5; } jsFiddle Demo...
Here is the solution .green-circle { color: green; border: 2px solid green; border-radius: 100%; height: 200px; width: 200px; position: relative; } .red-circle { color: red; border: 2px solid red; border-radius:...