I can't figure out how to do this with CSS. If I just use a <br>
tag, it works flawlessly, but I'm trying to avoid doing that for obvious reasons.
Basically, I just want the .feature_desc
span
to start on a new line, but:
.feature_wrapper
will be a slightly different size, but none will ever be as wide as the entire screen.)Example code: This works, but uses a br
tag:
<li class='feature_wrapper' id='feature_icon_getstart'> <span style='display: none;' class='search_keywords'>started</span> <span class='feature_icon spriteicon_img' id='icon-getstart'><a href='getstarted/index.html' class='overlay_link'></a></span><br/> <span class='feature_desc'><a href='getstarted/index.html' >Getting Started Wizard</a></span> </li>
I want to style this with CSS to achieve the same result:
<li class='feature_wrapper' id='feature_icon_getstart'> <span style='display: none;' class='search_keywords'>started</span> <span class='feature_icon spriteicon_img' id='icon-getstart'><a href='getstarted/index.html' class='overlay_link'></a></span> <span class='feature_desc'><a href='getstarted/index.html' >Getting Started Wizard</a></span> </li>
Any ideas? Or am I going about this the wrong way?
You can manipulate how an element behaves on the page by modifying its display property in CSS. You can set a block-level element to display like an inline element by setting the display property to inline. You can also cause inline elements to behave like block-level elements using the display property.
Inline elements are those which only occupy the space bounded by the tags defining the element, instead of breaking the flow of the content. Note: An inline element does not start on a new line and only takes up as much width as necessary.
Generally, block-level elements may contain inline elements and (sometimes) other block-level elements. Inherent in this structural distinction is the idea that block elements create "larger" structures than inline elements.
You can give it a property display block; so it will behave like a div and have its own line
CSS:
.feature_desc { display: block; .... }
Even though the question is quite fuzzy and the HTML snippet is quite limited, I suppose
.feature_desc { display: block; } .feature_desc:before { content: ""; display: block; }
might give you want you want to achieve without the <br/>
element. Though it would help to see your CSS applied to these elements.
NOTE. The example above doesn't work in IE7 though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With