gpt4 book ai didi

html - 在 元素下居中 元素

转载 作者:太空宇宙 更新时间:2023-11-03 22:39:52 24 4
gpt4 key购买 nike

我试图将几个 span 集中在他们的 fontawesome 图标下。如果我设置边距,它显然不起作用,因为所有跨度(带文本)的宽度都不相同。

代码笔 here

$(document).ready(function(){
$("#navi").click(function(){
$("#navi .fa-chevron-down").toggleClass("rtoate180");
$("#navigation").slideToggle(500);
});
});
  #navi {
cursor: pointer;
margin-top: 10px;
margin-left: 20px;
width: 170px;
height: 30px;
line-height: 30px;
padding-left: 10px;
overflow: hidden;
color: #000000;
background: #f67e7d;
font-size: 12px;
text-align: left;
}

#navi i {
position: absolute;
margin-left: 77px;
margin-top: 10px;
color: #000000!important;
font-size: 12px;
}

#navi .fa-chevron-down {
-webkit-transition: all 0.7s ease;
-moz-transition: all 0.7s ease;
-ms-transition: all 0.7s ease;
-o-transition: all 0.7s ease;
transition: all 0.7s ease;
}

.rtoate180 {
transform: rotate(180deg);
}

#navigation {
margin-top: 10px;
margin-left: 20px;
width: 180px;
overflow: hidden;
display: none;
background: #f67e7d;
}

#navigationin span {
color: #ffb997;
font-size: 10px;
position:fixed;
margin:35px 0 0 -35px;
text-transform:lowercase;
text-align:center;
}

#navigation i {
display: inline-block;
color: #000000!important;
margin: 10px;
font-size: 15px;
padding:5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<div id="navi"> NAVIGATION <i class="fa fa-chevron-down"></i></div>

<!--Navigation-->
<div id="navigation">

<div id="navigationin"><center>
<a href="{text:Link One Url}"><i class="fa fa-user-circle"></i><span>my stuff</span></a>
<a href="{text:Link Two Url}"><i class="fa fa-question-circle"></i><span>tutorials</span></a>
<a href="{text:Link Nine Url}"><i class="fa fa-folder-open-o"></i><span>archive</span></a>
<a href="{text:Link Three Url}"><i class="fa fa-star"></i><span>actors</span></a>
<a href="{text:Link Four Url}"><i class="fa fa-film"></i><span>tv shows</span></a>
<a href="{text:Link Eight Url}"><i class="fa fa-link"></i><span>links</span></a>
<a href="{text:Link Five Url}"><i class="fa fa-file-video-o"></i><span>gifsets</span></a>
<a href="{text:Link Six Url}"><i class="fa fa-file-image-o"></i><span>photosets</span></a>
<a href="{text:Link Seven Url}"><i class="fa fa-square-o"></i><span>icons</span></a>
<a href="{text:Twitter url}" target="_blank"><i class="fa fa-twitter-square"></i><span>twitter</span></a>
<a href="{text:Instagram url} target="_blank""><i class="fa fa-instagram"></i><span>instagram</span></a>
<a href="{text:Youtube url}" target="_blank"><i class="fa fa-youtube"></i><span>youtube</span></a>
</center>
</div>

</div>

目前它不是很好,底部文本太大并且超出了边缘但我稍后会处理它。^^ 我只想首先垂直居中。谢谢!

最佳答案

像这样?

添加:

#navigation a {
display: inline-block;
text-decoration: none;
}

改变#1

#navigationin span {
color: #ffb997;
font-size: 10px;
position:fixed;
margin:35px 0 0 -35px;
text-transform:lowercase;
text-align:center;
}

收件人:

#navigationin span {
color: #ffb997;
font-size: 10px;
display: inline-block;
text-transform:lowercase;
text-align:center;
}

改变#2

#navigation i {
display: inline-block;
color: #000000!important;
font-size: 15px;
margin: 10px 10px 0 10px;
padding:5px;
}

收件人:

#navigation i {
display: block;
color: #000000!important;
font-size: 15px;
margin: 10px 10px 0 10px;
padding:5px;
}

#navigationin span位置固定。滚动时,它溢出了图标。我不知道这是否是所需的行为?

$(document).ready(function(){
$("#navi").click(function(){
$("#navi .fa-chevron-down").toggleClass("rtoate180");
$("#navigation").slideToggle(500);
});
});
#navi {
cursor: pointer;
margin-top: 10px;
margin-left: 20px;
width: 170px;
height: 30px;
line-height: 30px;
padding-left: 10px;
overflow: hidden;
color: #000000;
background: #f67e7d;
font-size: 12px;
text-align: left;
}

#navi i {
position: absolute;
margin-left: 77px;
margin-top: 10px;
color: #000000!important;
font-size: 12px;
}

#navi .fa-chevron-down {
-webkit-transition: all 0.7s ease;
-moz-transition: all 0.7s ease;
-ms-transition: all 0.7s ease;
-o-transition: all 0.7s ease;
transition: all 0.7s ease;
}

.rtoate180 {
transform: rotate(180deg);
}

#navigation {
margin-top: 10px;
margin-left: 20px;
width: 180px;
overflow: hidden;
display: none;
background: #f67e7d;
}

#navigation a {
display: inline-block;
text-decoration: none;
}

#navigationin span {
color: #ffb997;
font-size: 10px;
display: block;
text-transform:lowercase;
text-align:center;
}

#navigation i {
display: block;
color: #000000!important;
font-size: 15px;
margin: 10px 10px 0 10px;
padding:5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<div id="navi"> NAVIGATION <i class="fa fa-chevron-down"></i></div>

<!--Navigation-->
<div id="navigation">

<div id="navigationin"><center>
<a href="{text:Link One Url}"><i class="fa fa-user-circle"></i><span>my stuff</span></a>
<a href="{text:Link Two Url}"><i class="fa fa-question-circle"></i><span>tutorials</span></a>
<a href="{text:Link Nine Url}"><i class="fa fa-folder-open-o"></i><span>archive</span></a>
<a href="{text:Link Three Url}"><i class="fa fa-star"></i><span>actors</span></a>
<a href="{text:Link Four Url}"><i class="fa fa-film"></i><span>tv shows</span></a>
<a href="{text:Link Eight Url}"><i class="fa fa-link"></i><span>links</span></a>
<a href="{text:Link Five Url}"><i class="fa fa-file-video-o"></i><span>gifsets</span></a>
<a href="{text:Link Six Url}"><i class="fa fa-file-image-o"></i><span>photosets</span></a>
<a href="{text:Link Seven Url}"><i class="fa fa-square-o"></i><span>icons</span></a>
<a href="{text:Twitter url}" target="_blank"><i class="fa fa-twitter-square"></i><span>twitter</span></a>
<a href="{text:Instagram url} target="_blank""><i class="fa fa-instagram"></i><span>instagram</span></a>
<a href="{text:Youtube url}" target="_blank"><i class="fa fa-youtube"></i><span>youtube</span></a>
</center>
</div>

</div>

关于html - 在 <i> 元素下居中 <span> 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44498253/

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