如何在div
容器内对齐图片,使其与宽度相符?
这是我走了多远
<head>
<style>
#left {
background-color:#81CFE0;
height:100%;
width:25%;
float:left;
}
#img {
display: block;
margin-left: auto;
margin-right: auto;
}
</style>
<meta charset="utf-8">
</head>
<body>
<div id="left">
<img src="/img/001.jpg">
This is a Picture of something representing something
</body>
&#13;
提前感谢您的帮助!
答案 0 :(得分:1)
您的代码中存在很多错误,但这应该有效:
#left {
background-color:#81CFE0;
height:100%;
width:25%;
float:left;
}
img {
width:100%;
}
&#13;
<div id="left">
<img src="/img/001.jpg"/>
</div>
&#13;