Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 向左浮动,但在屏幕上的某个点停止调整大小?_Html_Css - Fatal编程技术网

Html 向左浮动,但在屏幕上的某个点停止调整大小?

Html 向左浮动,但在屏幕上的某个点停止调整大小?,html,css,Html,Css,我有一个div扩展了页面的高度,左侧为float,例如: #leftvignette { width: 200px; height: 100%; float: left; } #sitecontent { margin: auto; width: 1000px; } HTML: 这里的所有其他内容 我希望这个div始终位于我的内容的左侧,直到窗口宽度小于1000px-我不希望#leftvignette侵入并覆盖我的内容 有人知道这样做的方法吗?\le

我有一个div扩展了页面的高度,左侧为float,例如:

#leftvignette {
    width: 200px;
    height: 100%;
    float: left;
}
#sitecontent {
    margin: auto;
    width: 1000px;
}
HTML:


这里的所有其他内容
我希望这个div始终位于我的内容的左侧,直到窗口宽度小于1000px-我不希望
#leftvignette
侵入并覆盖我的内容

有人知道这样做的方法吗?

\leftvignette{
#leftvignette {
    width: 200px;
    height: 100px;
    float: left;
    background:#000;
}
#sitecontent {
    margin: auto;
    width: 1000px;
    background:#f00;
    height:200px;
    float:left;
}
.clear{clear:both;}


<div id="leftvignette"></div>    
<div id="sitecontent">
    all other content here
</div>
<div class="clear">
<!--this will help in clearing float for next comming elements.-->
</div>
宽度:200px; 高度:100px; 浮动:左; 背景:#000; } #网站内容{ 保证金:自动; 宽度:1000px; 背景:#f00; 高度:200px; 浮动:左; } .clear{clear:两者;} 这里的所有其他内容
使用CSS媒体查询和CSS clear属性删除浮动:

@media all and (max-width: 1000px) {
  #leftvignette {
    clear:both;
}
}

低于1000px的任何内容都将删除float:left。

我建议您创建一些util类,例如
。清除
,并在需要时将它们作为类应用于html中

CSS:

.clear{
   clear:both;
}
HTML

<div id="leftvignette" class="clear"></div> 
<div id="leftvignette" class="clear"></div> 
@media screen and (max-width:1000px){
     #leftvignette{
        clear:both;
     }
}