简体   繁体   English

存在浮点时,如何使H4元素的行为像HR

[英]How can I make an H4 element behave like an HR when floats are present

Here's my code: 这是我的代码:

http://jsfiddle.net/beA4a/ http://jsfiddle.net/beA4a/

<div style="float:right; width:200px; border:solid 1px #000; height:300px;"></div>
<p>Text</p>
<hr/>
<h4 style="border-bottom:solid 1px #000;">H4 Text</h4>

Notice how the hr stops at the floated div but the h4 passes right thru it. 注意hr如何在浮动div处停止的,而h4则通过它。 Is there any CSS I can apply to the h4 to make it behave the same way without specifying a width on the h4? 我可以将任何CSS应用于h4,使其行为相同,而无需在h4上指定宽度吗?

I want it so that if the h4 was pushed below the floated div it would then take up the full page width as the hr would. 我想要这样,如果将h4推到浮动div下方,则它将像hr一样占据整个页面宽度。

Just add overflow: hidden to the h4 只需添加overflow: hiddenh4

h4{
   overflow:hidden;
}

Demo 演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 悬停时如何更改H4的颜色 - How to change color of H4 when hovering 如何使表格单元的行为类似于UL LI? - How can I make table cells behave like UL LIs? 我如何向此列表项添加 H 标签,我想要 H4 - How i can add a H tag to this List Item, I Want H4 如何从HTML字符串(如编号TOC)仅提取标题(即h2,h3,h4)? - How to extract only the headings (i.e h2,h3,h4), from a html string like a numbered TOC? 如何在Flex显示中使文本直接在h4下对齐? - How do I make text align directly under h4 in flex display? 如何在导航栏中对齐h4和img元素? - How to align a h4 and img element within a navbar? 如何让父元素在大小上表现得与子元素完全一样? - How can I let a parent element behave exactly like its child in terms of size? 如何在其中添加一个元素<h4>通过除“值”之外的其他 select 选项下拉列表进行标记,因为我已经使用过它,这可能吗?”</h4> - how to add an element in <h4> tag through other select option dropdown apart from "value" because I already used it, is It possible?" 使用CSS flex,如何在标题之后到行尾之间获得一行(如hr元素) - Using CSS flex, how can I get a line (like the hr element) starting after my title to the end of the line 如何让DIV像IMG一样用作CSS精灵呢? - How can I make a DIV behave like an IMG for use as a CSS sprite?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM