Html 用CSS对图像进行定心
我试图简单地使用CSS和一些调整大小的机制将图像居中,但我就是不明白。它总是左对齐的 我们将不胜感激 代码如下:Html 用CSS对图像进行定心,html,css,image,centering,Html,Css,Image,Centering,我试图简单地使用CSS和一些调整大小的机制将图像居中,但我就是不明白。它总是左对齐的 我们将不胜感激 代码如下: <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> <style type="text/css"> .img { display: block; margin:0 auto; max-width: 900px;
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
.img {
display: block;
margin:0 auto;
max-width: 900px;
top:10px;
width: 60%;
height: 70%;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<img class="img" src="gP.png" alt="..." />
</asp:Content>
10/10/2007
10/10/2007
好极了!成功了当用户调整浏览器的大小时,有没有办法调整它的高度?我的意思是,始终保持图像大小为broser高度的80%?正如您所看到的,您的代码没有任何问题。可能您有其他元素的css与图像css交互
试试这个,看看它是否有效:
.img {
display: block;
margin:0 auto !important;
max-width: 900px;
top:10px;
width: 60%;
height: 70%;
}
不能将父元素与
文本对齐:居中代码>?能否创建一个小提琴来重新创建此错误?根据您提供的CSS,我看不到它:正如@circle73所指出的,这里有一个更新版本,其中父容器只应用了text align:center
:不,没有这样做(可能是母版页上的内容?尝试添加padding:0 auto;
padding:0 auto;也不起作用。我在上面的问题中发布了母版页代码。émais fácil assim..估计一个ler o teu código total e não Encentrei aárestás a inserir a imagem com a classeimg@Tiago卡索·塞贾·埃斯塔
vais ter de a colo汽车车身div.container
ou ento adicionarestext align:center;
a tua tagbody
tipo assimbody{text align:center;}
.img {
display: block;
margin:0 auto !important;
max-width: 900px;
top:10px;
width: 60%;
height: 70%;
}