/* button gifs */
.button-gifs {
display:inline-block;
margin-left: auto;
margin-right: auto;
width: 10%;
padding: 5px;
align:center;
min-width: 120px;
}
/* Ion Cannon */
.earth{
width: 150px;
height: 150px;
background: url(https://i.imgur.com/ubEXxDA.png);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.earth:hover{
background: url(https://i.imgur.com/MDbvuYW.gif);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
/* dachshund head */
.dachshund-head{
width: 150px;
height: 150px;
background: url(https://i.imgur.com/XDPDMXu.png);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.dachshund-head:hover{
background: url(https://i.imgur.com/GICiErd.gif);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
/* ChickenWifRabies */
.ChickenWifRabies{
width: 150px;
height: 150px;
background: url(https://i.imgur.com/wqBqdjb.png);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.ChickenWifRabies:hover{
background: url(https://i.imgur.com/8H4lx1u.gif);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
/* Gateways */
.Gateways{
width: 150px;
height: 150px;
background: url(https://i.imgur.com/kunVntT.png);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.Gateways:hover{
background: url(https://i.imgur.com/7gth567.gif);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
/* Games */
.Games{
width: 150px;
height: 150px;
background: url(https://i.imgur.com/0gwiz6c.png);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.Games:hover{
background: url(https://i.imgur.com/3w29EWf.gif);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
/* Pride */
.Pride{
width: 150px;
height: 150px;
background: url(https://i.imgur.com/ZVQmYAu.png);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.Pride:hover{
background: url(https://i.imgur.com/ErHvozs.gif);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
/* Learning */
.Learning{
width: 120px;
height: 150px;
background: url(https://i.imgur.com/1yn3nlz.png);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.Learning:hover{
background: url(https://i.imgur.com/LAKluIV.gif);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}<!-- Ion Canon -->
<div class="earth button-gifs" onclick="window.location.href='#space'" style="cursor: pointer;"></div>
<!-- Dachshund Head -->
<div class="dachshund-head button-gifs" onclick="window.location.href='#dog'" style="cursor: pointer;"> </div>
<!-- ChickenWifRabies -->
<div class="ChickenWifRabies button-gifs" onclick="window.location.href='#chickens'" style="cursor: pointer;"></div>
<!-- Gateways -->
<div class="Gateways button-gifs" onclick="window.location.href='#metal'" style="cursor: pointer;"></div>
<!-- Games -->
<div class="Games button-gifs" onclick="window.location.href='#gaming'" style="cursor: pointer;"></div>
<!-- Pride -->
<div class="Pride button-gifs" onclick="window.location.href='#pride'" style="cursor: pointer;" ></div>
<!-- Learning -->
<div class="Learning button-gifs" onclick="window.location.href='#learning'" style="cursor: pointer;"></div>
<!-- Bananaman Gif -->
<a target="_blank" href="https://www.youtube.com/embed/yModCU1OVHY">
<img id="gif-2" class="button-gifs" src="https://i.imgur.com/QpylKJJ.png"
onmouseover="document.getElementById('gif-2').src='https://i.imgur.com/F5eUUiV.gif'"
onmouseout="document.getElementById('gif-2').src='https://i.imgur.com/QpylKJJ.png'" </img></a>
所以..。我很累,我尝试了很多不同的东西,浮动,转置,等等,似乎找不到办法让这些按钮的坐在页面的顶部和居中的。Bananaman是我第一次把它做成一个按钮,我可以把它变成和其他人一样的方式,但我已经被淹没了。我为这个网站使用的视频背景给了我一些问题,但我修复了它。我只想知道我能做些什么才能让这件事奏效。
发布于 2021-05-02 06:31:21
如果您只想对内容进行水平居中,可以添加一个简单的内容包装器div,如下所示:
.content {
position: absolute;
/* center the element */
right: 0;
left: 0;
margin-right: auto;
margin-left: auto;
/* give it dimensions */
width: 80%;
}
/* button gifs */
.button-gifs {
display:inline-block;
margin-left: auto;
margin-right: auto;
width: 10%;
padding: 5px;
align:center;
min-width: 120px;
}
/* Ion Cannon */
.earth{
width: 150px;
height: 150px;
background: url(https://i.imgur.com/ubEXxDA.png);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.earth:hover{
background: url(https://i.imgur.com/MDbvuYW.gif);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
/* dachshund head */
.dachshund-head{
width: 150px;
height: 150px;
background: url(https://i.imgur.com/XDPDMXu.png);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.dachshund-head:hover{
background: url(https://i.imgur.com/GICiErd.gif);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
/* ChickenWifRabies */
.ChickenWifRabies{
width: 150px;
height: 150px;
background: url(https://i.imgur.com/wqBqdjb.png);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.ChickenWifRabies:hover{
background: url(https://i.imgur.com/8H4lx1u.gif);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
/* Gateways */
.Gateways{
width: 150px;
height: 150px;
background: url(https://i.imgur.com/kunVntT.png);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.Gateways:hover{
background: url(https://i.imgur.com/7gth567.gif);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
/* Games */
.Games{
width: 150px;
height: 150px;
background: url(https://i.imgur.com/0gwiz6c.png);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.Games:hover{
background: url(https://i.imgur.com/3w29EWf.gif);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
/* Pride */
.Pride{
width: 150px;
height: 150px;
background: url(https://i.imgur.com/ZVQmYAu.png);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.Pride:hover{
background: url(https://i.imgur.com/ErHvozs.gif);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
/* Learning */
.Learning{
width: 120px;
height: 150px;
background: url(https://i.imgur.com/1yn3nlz.png);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.Learning:hover{
background: url(https://i.imgur.com/LAKluIV.gif);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}<div class="content">
<!-- Ion Canon -->
<div class="earth button-gifs" onclick="window.location.href='#space'" style="cursor: pointer;"></div>
<!-- Dachshund Head -->
<div class="dachshund-head button-gifs" onclick="window.location.href='#dog'" style="cursor: pointer;"> </div>
<!-- ChickenWifRabies -->
<div class="ChickenWifRabies button-gifs" onclick="window.location.href='#chickens'" style="cursor: pointer;"></div>
<!-- Gateways -->
<div class="Gateways button-gifs" onclick="window.location.href='#metal'" style="cursor: pointer;"></div>
<!-- Games -->
<div class="Games button-gifs" onclick="window.location.href='#gaming'" style="cursor: pointer;"></div>
<!-- Pride -->
<div class="Pride button-gifs" onclick="window.location.href='#pride'" style="cursor: pointer;" ></div>
<!-- Learning -->
<div class="Learning button-gifs" onclick="window.location.href='#learning'" style="cursor: pointer;"></div>
<!-- Bananaman Gif -->
<a target="_blank" href="https://www.youtube.com/embed/yModCU1OVHY">
<img id="gif-2" class="button-gifs" src="https://i.imgur.com/QpylKJJ.png"
onmouseover="document.getElementById('gif-2').src='https://i.imgur.com/F5eUUiV.gif'"
onmouseout="document.getElementById('gif-2').src='https://i.imgur.com/QpylKJJ.png'" </img></a>
</div>
发布于 2021-05-02 06:27:48
将align: center更改为vertical-align: top
.button-gifs {
display: inline-block;
margin-left: auto;
margin-right: auto;
width: 10%;
padding: 5px;
vertical-align: top;
min-width: 120px;
}https://stackoverflow.com/questions/67353278
复制相似问题