我在这里有一个JSFiddle:http://jsfiddle.net/PEHbr/1 出于某种原因,我无法将图像高度设置为50%。
<div class="column img">
<div class="images right">
<img src="{path-to-image}" />
</div>
</div>
CSS:
.row {
display: table-row;
width: 100%;
}
.column { display: table-cell; height: 100%; position: relative; }
.img { width: 22%; }
.txt { width: 50%; vertical-align: middle; }
.text p {
width: 90%;
margin: 10px auto;
line-height: 1.5;
white-space: pre-wrap;
font-size: 18px;
font-family: Lato;
}
.right { text-align: right; }
.images { height: 100%; position: relative; }
.images img { height: 50%; }
为什么我无法正确编辑图像的高度?
编辑:
我已经替换了图片的src
,它可以处理比他们高和正方形更宽的图像,但我想要使用的图像是高大的矩形,这些都不起作用。这是为什么?
答案 0 :(得分:0)
它对我有用。也许你的项目中还有另一个css文件或代码来链接你的图片大小!!!
<style type="text/css">
.row {
display: table-row;
width: 100%;
}
.column {
display: table-cell;
height: 100%;
position: relative;
}
.img {
width: 22%;
}
.txt {
width: 50%;
vertical-align: middle;
}
.text p {
width: 90%;
margin: 10px auto;
line-height: 1.5;
white-space: pre-wrap;
font-size: 18px;
font-family: Lato;
}
.right {
text-align: right;
}
.images {
height: 100%;
position: relative;
}
.images img {
height: 50%;
}
.images20 img {
height: 10%;
}
</style>
<div class="column img">
<div class="images right">
<img src="img.jpg" />
</div>
</div>
<div class="column img">
<div class="images20 right">
<img src="img.jpg" />
</div>
</div>
答案 1 :(得分:0)
请在下页的左框中查看此代码
http://www.w3schools.com/html/tryit.asp?filename=tryhtml_intro
<style type="text/css">
.row {
display: table-row;
width: 100%;
}
.column {
display: table-cell;
height: 100%;
position: relative;
}
.img {
width: 22%;
}
.txt {
width: 50%;
vertical-align: middle;
}
.text p {
width: 90%;
margin: 10px auto;
line-height: 1.5;
white-space: pre-wrap;
font-size: 18px;
font-family: Lato;
}
.right {
text-align: right;
}
.images {
height: 100%;
position: relative;
}
.images img {
height: 50%;
}
.images20 img {
height: 20%;
}
/* 50% */
</style>
<div class="column img">
<div class="images right">
<img src="http://2.179.254.185/images/button/signout.png" />
</div>
</div>
<div class="column img">
<div class="images20 right">
<img src="http://2.179.254.185/images/button/signout.png" />
</div>
</div>