How to make an inline element appear on new line, or block element not occupy the whole line?
Tags: html,css
Problem :
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:
- If I make it an inline element, it won't have a line-break.
- If I make it a block element, it will expand to fit the entire line, putting each of these icons on its own line, and wasting tons of space on the screen (each
.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?
Solution :
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;
....
}
CSS Howto..
On the Style ∇ tab, click the down arrow ∇ and select Only Show Applied Styles
You can use viewport unit vw to define the width of child div. A width of 100vw will take the entire screen width. Example - .parent { width: 300px; }...
The solution can you find here: https://css-tricks.com/how-nth-child-works/ In your situation, I think you need is :nth:child(7n+5){ } Explanation: 7n are the steps you have to set, 5 is the starting...
You need CSS clipping. The below CSS should give you the desired effect. -webkit-clip-path: polygon(0 0, 100% 0%, 100% 100%, 0 54%); clip-path: polygon(0 0, 100% 0%, 100% 100%, 0...
I just read your edit, and while it seems you're gone I am going to answer anyway. Don't give up. CSS can be frustrating to troubleshoot and troublesome to implement...
Use flex model Add: #parent { display: flex; flex-direction: column; } fieldset { flex: 0px 1 1; } snippet #window { width: 600px; height: 600px; display: table; background: yellow; }...
Google uses two divs which are absolutely positioned on top of the input box. The first div contains the word stackoverflow, and the text is styled in a light gray....
If this is an issue of specificity, you could be more specific and use something like this: form .form-group .form-error { border: 2px solid red; } jsFiddle example Remember, stylesheets...
Note the additional position: relative on .number. Jsfiddle. .number { width: 8em; display: block; word-wrap: break-word; columns: 5; -webkit-columns: 5; -moz-columns: 5; column-gap: 0.2em; -webkit-column-gap: 0.2em; -moz-column-gap: 0.2em; text-decoration: underline;...
You can use verifyElementPresent command to check if specific UI element exist on the page. So to check if a parent div (with id='delay') has children div you can just...
Instead of relying on float/clear to expand past the bounds of story-container you can instead add a new class story-row and set it's width to be very large. <div class="story-container">...
@import url("abc.css") (width: 1360px); @import url("xyz.css") (width: 1600px); @import supports media queries. Demo: http://jsfiddle.net/DerekL/assz3/...
You have got so many good answers and here's mine also. If you want to element in same row then you can use float or display:inline-block;. As per your given...
These kind of questions are just fun to answer step-by-step. The basics of the solution is to display all list items as inline-block: .calendar > ol > li { display:...
Firstly, Add a <!DOCTYPE> to your code: <!DOCTYPE html> And when you add <!DOCTYPE> your code stop working for all browser, because of a small reason, you were missing to...
try like this src: url("/Content/Travelo/fonts/oap-icons.eot?26664784") or try moving your fonts to default fonts folder of MVC application...
I'd recommend using CSS transitions as they have better browser coverage, they are simpler to manage and they fallback better (if the browser doesn't support transitions it does the same...
Or is it any other better way? Are you really asking how to set a background (color) with CSS? You should have a look at the w3 tutorial about...
Try setting the border-radius just for the top right and top left corners using: border-top-left-radius: 80px; border-top-right-radius: 80px; Note: I used 80px not 50%, as 80px is half of the...
Here i have applied/fixed your codes for the menu you are trying to achieve. You can change Background Color and Font Color easily. Wish this work for you. #horizontalmenu ul...
You need last-of-type and > .list > li:last-of-type { color: red; } <ul class="list"> <li>a <ul> <li>a</li> </ul> </li> <li>c</li> </ul> As you mention that you want last element of...
I think what you want is an accordion. Accordion is a UI design and is available in many major libraries. It will take quite some effort if you want to...
With your existing code, all you need to do is to remove float:left; and add display: table. #header ul { width: 100%; display: table; .... And here is your code...
If you want the link to open up a new browser window, you need the 'target' attribute on the anchor tag, like this: <a href="other-page.php" target="_blank"> If you don't want...
You need a higher z-index for the hamb. Remember z-index works just for positioned elements, you need to change the default static position of the button. .overlay { position: fixed;...
You can import the CSS file like stara_wiedzma said. However you can't import bootstrap's .btn class for input[Type=button], input[Type=submit], input[Type=reset] globally with CSS I think you are looking for something...
This might get you started. I always fall back on this solution. Not too hack-ish and gets the job done. EDIT: I should point out that you might achieve the...
Took me a long time, but yes. It's effectively the same idea as yours but uses zero width containers to push down the shapes. .pusher { display: block; width: 0px;...
I see at least two options: 1.Detect mobile browser with JavaScript. Link here: javascript - How to detect mobile device and get user agent info send and save that information...
You could use your normal stylsheet on all the pages, with the solid white background set. Then on your front page and other 'special' pages, you could have a tag...