gpt4 book ai didi

html - 如何使字形或图像在 sidenav 中正确对齐

转载 作者:行者123 更新时间:2023-11-28 13:55:09 24 4
gpt4 key购买 nike

我怎样才能使图片或字形图标始终位于右侧,而不管文本的长度如何?在当前表单中,如果左侧的文本被放大,则对齐会丢失。我尝试使用 align="right"但它不起作用,有什么想法吗?

#mySidenav a {
position: fixed;
left: -145px;
transition: 0.3s;
padding: 15px;
width: 180px;
text-decoration: none;
font-size: 20px;
color: white;
border-radius: 0 5px 5px 0;
z-index: 100;
}

#mySidenav a:hover {
left: 0;
}

#about {
top: 80px;
background-color: #4CAF50;
}

#blog {
top: 140px;
background-color: #2196F3;
}

#projects {
top: 200px;
background-color: #f44336;
}

#contact {
top: 260px;
background-color: #555
}
<div id="mySidenav" class="sidenav">
<a href="#" id="about">Money: 500 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&euro;</a>
<a href="#" id="blog">test: &nbsp;&nbsp;&nbsp; <span class="glyphicon glyphicon-bell" align="right"></span></a>
<a href="#" id="projects">test</a>
<a href="#" id="contact">Contact</a>
</div>

最佳答案

清理   并在 $euro 和 css 等图标上使用 .glyphicon 类向右浮动

#mySidenav a {
position: fixed;
left: -145px;
transition: 0.3s;
padding: 15px;
width: 180px;
text-decoration: none;
font-size: 20px;
color: white;
border-radius: 0 5px 5px 0;
z-index: 100;
}

#mySidenav a:hover {
left: 0;
}

#about {
top: 80px;
background-color: #4CAF50;
}

#blog {
top: 140px;
background-color: #2196F3;
}

#projects {
top: 200px;
background-color: #f44336;
}

#contact {
top: 260px;
background-color: #555
}

.glyphicon {
float: right;
}
<div id="mySidenav" class="sidenav">
<a href="#" id="about">Money: 500 <span class="glyphicon">&euro;</span></a>
<a href="#" id="blog">test: <span class="glyphicon glyphicon-bell">🔔</span></a>
<a href="#" id="projects">testtesttesttesttesttesttesttesttesttesttesttesttesttest</a>
<a href="#" id="contact">Contact</a>
</div>

关于html - 如何使字形或图像在 sidenav 中正确对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58753789/

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