简体   繁体   English

响应式网站 - 调整问题?

[英]Responsive Website - Sizing Issues?

I am currently creating a general responsive template for myself , as I have not really touched this side of design as of yet. 我目前正在为自己创建一个通用的响应式模板,因为我还没有真正触及过设计的这一方面。

I am having a issue with my "Content Div" when resizing to about 600px (A red border will appear when the resolution is right as to where the problem is). 当调整大小到600px时,我的“内容分区”出现问题(当分辨率正确时,会出现红色边框)。 My content div will no longer expand even though I have set a static height of 2300px , so the content just floats outside and the content div does not expand. 我的内容div将不再扩展,即使我已设置静态高度2300px,因此内容只浮动到外部,内容div不会扩展。

 @media only screen   
and (max-width : 603px) {  


/* Styles */  
#column_wrapper img {margin-left:25.33%;padding-right: 20%;}
#column1_content{height:500px;}
#column2_content{height:500px;}
#column3_content{height:500px;}
#column_wrapper{border:1px solid red;height:300px;float: left;}
#content{height:2300px;margin-top: 100px;margin-bottom: 20%;}

} 

The site can be found at Responsive Template 该网站可在响应式模板中找到

The problem happens when a floated element is within a container box, that element does not automatically force the container's height adjust to the floated element. 当浮动元素位于容器框内时,该问题就会发生,该元素不会自动强制容器的高度调整到浮动元素。 When an element is floated, its parent no longer contains it because the float is removed from the flow. 当一个元素浮动时,它的父元素不再包含它,因为浮动元素从流中移除。

You do not need to give height instead for div#content use clearfix. 您不需要为div而使用height#content use clearfix。 This will fix it ;) 这将解决它;)

.clearfix:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}

.clearfix {
display: inline-block;
}

 html[xmlns] .clearfix {
display: block;
}

* html .clearfix {
height: 1%;
}

don't use static height in div#content use only overflow:hidden; 不要在div中使用静态高度#content use only overflow:hidden; and remove too the static height in #column1_content, #column2_content and #column3_content 并删除#column1_content,#column2_content和#column3_content中的静态高度

relevant: http://www.quirksmode.org/css/clearing.html 相关: http//www.quirksmode.org/css/clearing.html

It's because the elements inside are floated. 这是因为里面的元素是浮动的。 When you float an element, it takes that element out of the content flow. 浮动元素时,它会将该元素从内容流中移出。 This means that those elements aren't going to push out the div and expand it with the content. 这意味着这些元素不会推出div并使用内容扩展它。

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

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