gpt4 book ai didi

css - 在 div 中居中图像

转载 作者:太空宇宙 更新时间:2023-11-04 00:07:29 25 4
gpt4 key购买 nike

大家好,我正在尝试将一些图像居中。它们一直向左浮动,我试过文本对齐,但似乎不起作用。 jsfiddle 在这里。 http://jsfiddle.net/E7Ydz/2/附言当我睡了一觉时,我可能会这样做,伦敦时间是 5:56 :(

[HTML]

<div id="portfolio" style="height: 3020px;">

<div id="project" class="cms design html-css " data-col="1" data-row="0" style="right: 0px; opacity: 1; top: 0px;">
<div id="workEntry1" class="workEntry">

<div id="thumbAttachment">
<div id="inThumb">
<img src="http://www.enjoythis.co.uk/wp-content/files_mf/work_thumbnail275.jpg">
</div>

<div id="blackCross"> <a href="http://www.enjoythis.co.uk/jane-stockdale/"><img src="http://www.enjoythis.co.uk/wp-content/themes/enjoyThis/images/thumb_transparency.png"></a></div>

</div>


<!--<div id="attachmentShadowThumb"></div>-->


<div id="workTitle">
</div>
<div id="workTags">


</div>
</div>
</div>


<div id="project" class="design illustration html-css " data-col="2" data-row="0" style="right: 0px; opacity: 1; top: 0px;">
<div id="workEntry2" class="workEntry">

<div id="thumbAttachment">
<div id="inThumb">
<img src="http://www.enjoythis.co.uk/wp-content/files_mf/work_thumbnail2.jpg">
</div>

<div id="blackCross"> <a href="http://www.enjoythis.co.uk/street-child-world-cup-i-am-somebody/"><img src="http://www.enjoythis.co.uk/wp-content/themes/enjoyThis/images/thumb_transparency.png"></a></div>

</div>


<!--<div id="attachmentShadowThumb"></div>-->


<div id="workTitle">
</div>
<div id="workTags">

</div>
</div>
</div>
<div id="project" class="app database design " data-col="0" data-row="1" style="right: 0px; opacity: 1; top: 0px;">
<div id="workEntry3" class="workEntry">

<div id="thumbAttachment">
<div id="inThumb">
<img src="http://www.enjoythis.co.uk/wp-content/files_mf/pgtips_thumb37.jpg">
</div>

<div id="blackCross"> <a href="http://www.enjoythis.co.uk/pg-tips-vs-january/"><img src="http://www.enjoythis.co.uk/wp-content/themes/enjoyThis/images/thumb_transparency.png"></a></div>

</div>


<!--<div id="attachmentShadowThumb"></div>-->


<div id="workTitle">
</div>
<div id="workTags">


</div>
</div>
</div>

[CSS]

#project{
float:left;
position:relative;
padding: 0px 0px 0px 2px;
height:200px;
width:309px;
display: inline;
}

.workEntry{
width:310px;
overflow:hidden;
}



#thumbAttachment{
float:left;
width: 310px;
height:200px;
overflow: hidden;
}

#inThumb{
float:left;
}

#blackCross{
float:left;
width: 310px;
height:200px;
margin-top:-200px;
khtml-opacity:0;
-moz-opacity:0;
-ms-filter:"alpha(opacity=0)";
filter:alpha(opacity=0);
opacity:0;

}

#blackCross:visited{

khtml-opacity:0;
-moz-opacity:0;
-ms-filter:"alpha(opacity=0)";
filter:alpha(opacity=0);
opacity:0;
}

#blackCross:hover{
khtml-opacity:1;
-moz-opacity:1;
-ms-filter:"alpha(opacity=100)";
filter:alpha(opacity=100);
opacity:100;
}

最佳答案

希望我能很好地理解您的问题。您应该使用 margin-left: auto;margin-right: auto; 来制作一个 div(或者更确切地说,一个 block 位置元素)居中。

例如,您应该将您的 css 代码更改为:

#inThumb{
margin-left: auto;
margin-right: auto;
}

请参阅此 jsFiddle:http://jsfiddle.net/E7Ydz/4/

关于css - 在 div 中居中图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14373017/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com