我试图将几个跨度置于他们真实的图标之下。如果我设置边距它显然不起作用,因为所有跨度(带有文本)都不具有相同的宽度。
Codepen 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>
&#13;
现在它不是很好,底部文字太大而且超出了边缘但我稍后会照顾它。^^我只想先垂直居中。谢谢!
答案 0 :(得分:3)
喜欢这个吗?
已添加:
#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;
}
position
#navigationin
的{{1}}为span
。滚动时,图标溢出。我不知道这是否是理想的行为?
fixed
&#13;
$(document).ready(function(){
$("#navi").click(function(){
$("#navi .fa-chevron-down").toggleClass("rtoate180");
$("#navigation").slideToggle(500);
});
});
&#13;
#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;
}
&#13;