How to make span width to be maximum using CSS?
Tags: html,css
Problem :
Consider the following example: (live demo)
HTML:
<div>
<p>
<strong>Stack</strong>
<span>Overflow</span>
</p>
</div>
CSS:
p {
background-color: #aaa;
}
span {
background-color: #777;
}
How could I make <span>
's width to be all the available space?
Note: <strong>
and <span>
should be on the same line.
Solution :
If you want the items on the same line with the full width taken up you could do this.
http://jsfiddle.net/Sohnee/Gfyjc/
p {
background-color: #aaa;
}
strong {
float: left;
}
span {
display: block;
background-color: #777;
margin-left: 40px;
}
But a better alternative would be to get the background-color run from the parent element.
CSS Howto..
There are two ways to achieve this (and you could even use both). If you want your style rules to apply here, you need to make them more specific than...
You could use animate(), then .remove() after the animation. Check out the fiddle - http://jsfiddle.net/8gavv7n2/2/ $('div').click(function(){ $('div').animate({opacity: 0}, 500, function(){ $(this).remove() }); }); You'll need to include jQueryUI too....
For solution 1: To make working margin:0 auto give display:block to div.whole For solution 2:: "The div elements is displayed vertically how to make it displayed horizontal" give class to...
The top: 50% trick won't be precise, since it will be a little lower, there are couple of tricks: Span position is absolute, top is 50% AND margin-top -> -50%...
Since a <p> is a block level element it will always force other content down. If you place the image inside the paragraph it floats within the paragraph to the...
Keep margin: 0 auto 0.55em; on figure > * and add display:block; I don't think margin: 0 auto works unless it's applied to block elements....
If you are looking for general solution (it means you don´t know image size, image count and don´t want to use negative top margin manually), you have to use multicolumn...
In order to get the most out of Bootstrap (especially the new "mobile first" features) I recommend using your Illustrator file as a jumping off point, rather than a spec....
You can't do that without giving the right labels a class or by using Javascript. With jQuery selectors you could do that: $("label:not(:has(radio))").addClass("boldmenow"); ... .boldmenow { font-weight: bold; } ...
there's a way to make anything centered. You don't need to know the height or width of any component, except the parent's. This involves a couple of things: heres a...
First of right click on web page. Click on inspect element option. I have attached one image that show the detail..
I'm not aware of a CSS-only solution, but you could set the width of the progress element before adding the class. In doing so, it will transition from the previous...
Yes, ther solution to your problem is using transform-style: preserve-3d. But the problem with this is that IE does not support this property A way to make it work in...
Go to http://getbootstrap.com/customize/ and toggle just what you want from the BS3 framework and then click "Compile and Download" and you'll get the CSS and JS that you chose. Open...
To achieve that you have to use table structure which mean make the li tag act as table and content act as tabel-cell and icon act as another table cell....
Though this is not entirely possible with CSS, this would work with the current example: EXAMPLE HERE div:not(.xpto) + div.xpto { display:block; } It basically just selects the succeeding .xpto...
You could just use: img { // Your styles for all images } However, if you want to add default class to all images, you need to use javascript: var...
Check out this DEMO, it should help you for sure. <nav id="main-nav"> <ul id="nav-primary"> <li><a href="#">Menu 1</a> <ul class="subnav"> <li><a href="#">beans</a> </li> <li><a href="#">pork chop</a> </li> </ul> </li> </nav>...
That css (calc()) is not supported in all browsers. You need to know the height of the current viewport and the height of div#box. Here's a way to determine both,...
Assuming you varaible is valid and holds something like "#f90", then you can do: style="color:<?= $values['color']; ?>;" or style="color:<?php echo $values['color']; ?>;" if you view/template is a .php then this...
"By looking at the code" You will never be absolutely sure, but you can get a very good indication from the CSS and the Viewport tag, as well as the...
This should work. Though it would probably better not to store the client name in the session variable but a more unique identifier. {{isSelected}} inserts selected into the list of...
The trick involves setting position: relative to the parent container .image-container which contains the image. Using display: inline-block will force the parent container to shrink-to-fit the image. You then apply...
There's a jQuery plugin for that. http://jquery.malsup.com/corner/
Try to set it to auto : right: auto; In your case it will be: #element { right: auto; } No need in jQuery! Working: http://jsfiddle.net/fEThD/1/...
What about a wrapping element? (JSFiddle) Edited by OP: This is what I ended up doing, since I already had a form element 'wrapping' the fieldset: HTML <form> <fieldset> </fieldset> </form>...
Whatever you've quoted from the documentation: The float CSS property specifies that an element should be taken from the normal flow and placed along the left or right side of...
You need to clear the floats. This is not only your age-old "problem", but every sitebuilder's. But luckily, age-old problems have age-old solutions. There are several clearing techniques available on...
CSS .fl20{float:left; padding:5px; margin:5px; width:120px;} .fl450{float:left; padding:5px; margin:5px; width:450px;} HTML <div class="fl20">Personen är sökande i:</div> <div class="fl450"> <input type="radio" name="<%= PandoraFieldConstants.FIELD_SOKANDE_I %>" value="alla">Alla länder...
If I understand you correctly, you want something like this fiddle shows (I changed the label to span). .caspName{ width: 105px; display: inline-block; margin-left: -110px; } .caspName:after{ content: ":"; }...