关于DIV中CSS无法显示背景颜色的问题解决

黄舟
Release: 2017-07-19 10:42:39
original
2492 people have browsed it

DIV CSS无法显示背景颜色问题分析解决 DIVCSS5经验教程篇

div css新手布局会遇到布局的背景颜色无法显示,一般布局背景无法显示通常原因如下:

1、由使用float浮动造成浮动产生无法显示css背景颜色
2、高度不够而产生背景无法显示

接下来我们分别介绍无法显示背景颜色或图片的原因和解决方法。

一、css float浮动产生浮动无法显示背景样式颜色   -   TOP

假设对一个对象设置了background背景颜色样式,该对象内部盒子有使用float浮动属性样式,这个时候该对象浮动产生,导致该对象不能撑开,所以css背景颜色就不能无法显示,解决方法有三种,一个是设置clear清除浮动、设置css高度、设置css overflow样式。

详细教程可进入:css清除浮动

二、高度限制造成了背景颜色不能显示完整   -   TOP

原因分析:
假如你有个对象没有计算好高度(或无意设置了一个很小高度属性样式),因为不确定内容有多少,当内容超过你设置高度限制,这个时候超出部分背景就可能无法显示。

解决方法:
设置够高的高度,或取消删除高度样式即可。

如果你想限制高度,又不想内容过多溢出你设置高度限制,解决教程:
css隐藏溢出超出DIV边框的内容

The above is the detailed content of 关于DIV中CSS无法显示背景颜色的问题解决. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Latest issues
Popular Tutorials
More>
Latest downloads
More>
web effects
Website source code
Website materials
Front end template
About us Disclaimer Sitemap
PHP Chinese website:Public welfare online PHP training,Help PHP learners grow quickly!