简体   繁体   中英

Making a div expand to available width, alongside an h1/h2 tag

Here's a JSFiddle:

http://jsfiddle.net/cKuUy/2/


Here's a screenshot of what I'm aiming for:

在此处输入图片说明

And what I'm getting in my browser:

在此处输入图片说明

The key difference is that in the actual implementation, the bars do not fill the available width of the containing div element. If I place: width:100% , the bar expands to it's container width, but goes down, below the text; despite both elements being floated left.

Any suggestions?

This solution should help: https://stackoverflow.com/a/1767270/1472586

Basically remove float: left and width from the bars and add overflow: hidden to them. You may also have to adjust your margins accordingly (right padding on the headings might work better, for example).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM