简体   繁体   English

字段集中的图例和清除向左浮动

[英]Legend inside fieldset and clearing float left

I found on this site solution about move legend in fieldset from border to inside fieldset. 我在此站点解决方案中发现了有关将图例从边界移动到内部的图例。 http://codepen.io/vkjgr/pen/oFdBa When I want to do this i should use float left style on legend, but I should use clear both after legend ? http://codepen.io/vkjgr/pen/oFdBa当我想执行此操作时,我应该在图例上使用左移样式,但是在图例之后我应该同时使用clear? This solution works on all browsers ? 此解决方案适用于所有浏览器吗? When I want clean I must use only clear both ? 当我想要清洁时,我必须只使用清除两者吗?

<fieldset>
<legende> xyz </legend>
<div style="clear: both;"</div>
//
// Other divs and inputs

If you want to follow your own approach, it also works as shown below. 如果您要遵循自己的方法,它也可以如下所示工作。 Otherwise, width:100% on legend will also do. 否则, legend上的width:100%也可以。

 fieldset { padding: 2em; } legend { float: left; } .clear { clear: both; } 
 <fieldset> <legend> Hello </legend> <div class="clear"> </div> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Neque sunt ad facilis fugiat perferendis et fugit quas, accusantium, quod atque provident natus facere animi sed accusamus qui doloribus illo nesciunt. </p> </fieldset> 

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

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