나는 다른 사람들이 같은 질문을 한 것을 보았지만 그 해결책은이 문제에 적용되지 않는다. 해결책은 iPhone, iPad 등의 다른 장치에서 작동하는 것이 가장 바람직하므로 일반적인 솔루션이 바람직합니다. 하나의 장치에서만 작동하는 것이 아닙니다. text-align:center
을 설정하려고 시도했으며 margin-left:auto
과 margin-right:auto
을 설정하려고 시도했지만 작동하지 않습니다.이미지를 연속으로 가운데에 배치하는 방법
html로 (단지 관련 코드 포함) :
<div class="container">
<div class="buttonyear"> <a href="en131.html"><img class="buttonyear" src="./navi/yearen.png" /><span>2014</span></a></div>
<div class="buttonyear"> <a href="en131.html"><img class="buttonyear" src="./navi/yearen.png" /><span>2013</span></a></div>
<div class="buttonyear clearfix"> <a href="en131.html"><img class="buttonyear" src="./navi/yearen.png" /><span>2012</span></a></div>
<br/>
<br/>
</div> <!-- end of navi -->
CSS는 :
.container {
max-width: 48rem;
width: 90%;
display: table-cell;
text-align: center;
vertical-align: middle;
}
body{
background-image: url(../images/gradient.jpg);
}
// todo improve css..ask on stackoverflow..
.navi {
width:100%;
text-align:center;
text-align: center;
margin-left: 42%;
margin-right: 42%;
}
.buttonyear
{
float: left;
}
.buttonyear a
{
text-decoration: none;
}
.logocontainer {
text-align:center;
}
.logo {
width:180px;
height:60px;
}
*, *:before, *:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
/* Small screens (default) */
html { font-size: 100%; }
/* Medium screens (640px) */
@media (min-width: 40rem) {
html { font-size: 112%; }
}
/* Large screens (1024px) */
@media (min-width: 64rem) {
html { font-size: 120%; }
}
ul {
list-style-type:none;
}
.buttonyear {
position: relative;
width: 42px;
height: 20px;
}
.buttonyear span {
left: 0;
position:absolute;
width: 100%;
color: white;
font: 12px Gill Sans;
font-weight:600;
text-decoration:none;
text-align:center;
width:42px;
height:20px;
padding-top:2px;
position:absolute;
}
.clearfix:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
.clearfix {
display: inline-block;
}
html[xmlns] .clearfix {
display: block;
}
* html .clearfix {
height: 1%;
}
바이올린 : http://jsfiddle.net/wzhwtvmt/
당신은 –
http://jsfiddle.net/wzhwtvmt/을 당신이 당신의 CSS의 .navi 클래스에 있지만, HTML에서 사용하는 –
이없는하시기 바랍니다 바이올린을 추가 할 수 있습니다. . 컨테이너를 집중하려고합니까? – dippas