banner图片css设置问题

html-css0106

banner图片css设置问题,第1张

你是要显示通栏导航的效果把?CSS完全可以实现:

将banner外面加个DIV,调用样式类nav,然后设置banner为1000像素宽,nav的设置自动:

【CSS部分】

<style>

.nav{width:autoheight:30pxbackground:url(img/bg.jpg) center center no-repeat}

.banner{width:1000pxheight:30pxmargin:0 auto}

.banner ul{width:1000pxheight:30px}

.banner ul li{width:100pxheight:30pxfloat:left}

</style>

【网页结构】

<div class="nav">

<div class="banner">

<ul>

<li>导航<li>

<li>导航<li>

<li>导航<li>

<li>导航<li>

<li>导航<li>

<ul>

</div>

</div>

这样就可以实现这个效果了

背景图宽度自适应方法:

添加css样式background-size:

100%

它的意思是规定背景图像的尺寸,但这个css样式使用时需要注意,有些浏览器是不支持,比如IE要求9+的版本才可以支持。

banner图自适应方法差不多,也是把图的宽度设置为百分比,容器的宽度依照窗口大小来设为百分比:

对图片添加宽度,因为不是背景图,所以对img添加css:

img

{

width:

100%

}

以上,希望对你有帮助,如果我没有说明白,可以追问。