欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

在网页html中,设置一个图片的宽高为什么其他的也一起变化?_html/css_WEB-ITnose

程序员文章站 2022-05-02 22:31:22
...
如下图:


带红框的图片是在同一个div中,的用鼠标调整一个图片的大小,其两个也会跟着变化,真是百思不得其解,倒底是怎么回事,请教了。

代码如下(打包成一个压缩文档了):
http://download.csdn.net/download/pengwei0417/8174545

不爱下载的我把代码粘上来:
这个是html文档的:
京东商城


这个是css文档的:
body{    margin: 0;    height: auto;    width: auto;}#content{    background-color: Aqua;    height: auto;    width: 990px;    margin: 0 auto;    font-size: 12px;}#head{    height: auto;    width: auto;    background-color: white;}#head #head1{    height: 110px;    width: 100%;    background-color: white;    position: relative;    top: 0px;    left: 0px;}#head1 a{    font-size: 14px;    position: absolute;    top: 46px;    left: 900px;    color: #666;}#head1 a:hover{    color: Red;}#head #head2{    height: 45px;    width: auto;    background-image: url(./Image/Nalist1.gif);    background-repeat: no-repeat;}#head #head2 ul{    width: auto;    width: auto;}#head #head2 li{    width: 120px;    height: 33px;    line-height: 33px;    float: left;}#nav #firsta{    background-image: url(./Image/Nalist_hover.gif);}#head #head2 a{    color: White;    font-size: 20px;    font-family: "黑体" ,Sans-Serif;    display: block;    width: 120px;    text-align: center;}#head #head2 a:hover{    background-image: url(./Image/Nalist_hover.gif);}#main{    height: auto;    width: 990px;    background-color: Red;}#main #leftmain{    height: auto;    width: 200px;    background-color: Teal;    float: left;    }#main #leftmain div{    width: 100%;    border:1px solid #ECECEC;   border-top-style:none;}#main #leftmain h1{    background-image: url(./Image/category_tree_bg.gif);    width: 200px;    font-size: 16px;    height: 27px;    line-height: 27px;}


回复讨论(解决方案)

你的这个InitialeCode.css文件中,有定义img的大小啊,如果你更改的话,是怎么改的?

img {display: block;height: 26px;width: 177px;}


上面的代码,是你的InitialeCode.css文件中的,你如果是更改这个,那么所有的img图片都会变化的。

LZ是不是将img这个标签 InitialeCode.css的line25这里面的属性改了?

这是会影响所有img标签的宽高. 你要在制定的标签中修改:

在网页html中,设置一个图片的宽高为什么其他的也一起变化?_html/css_WEB-ITnose

回楼上两位,跟初始化的CSS没关系,因为我改的方式是用鼠标拖拽一个图片的边调整大小时,另外两个图大小也跟着变化。
可以下载试一下。