gpt4 book ai didi

html - 如何在 CSS 和 HTML 上安排文本的顺序

转载 作者:太空宇宙 更新时间:2023-11-04 00:58:38 25 4
gpt4 key购买 nike

我想知道如何安排我网站上的文本顺序。在下面的图片中,我想让文本以不同的顺序显示并更改文本之间的间距。

我想把它改成“Work About Resume”而不是“Resume About Work”

此外,我稍后会添加到简历的正确链接。

https://imgur.com/a/ooGVqFP

谢谢!

HTML
<body>
<div class="page-wrapper">
<div class="home-page-wrapper">
<div id="navbar">
<a href="index.html" class="navbar-item" id="current-navbar-item" style="margin-left": 50px">Irene Li</a>
<a href="work.html" class="navbar-item" id="work-navbar-item" style="margin-right": 1000px">Work</a>
<a href="about.html" class="navbar-item" id="about-navbar-item" style="margin-right": 900px">About</a>
<a href="link" target="_blank" class="link, navbar-item" id="resume-navbar-item" style="margin-right": 800px">Resume</a>
</div>

CSS
#navbar {
width: 100%;
height: 100%;
font-family: 'Mukta', sans-serif;
}

.navbar-item {
display: inline-block;
margin-top: 40px;
margin-left: 45px;
text-decoration: none;
padding-bottom: 3px;
transition: .2s linear;
color: #3f3f3f;
font-size: 18px;
}

.navbar-item: hover {
border-bottom: 1.5px solid currentColor;
cursor: pointer;
transition: .2s linear;
}

#current-navbar-item {
color: #3f3f3f;
border-bottom: 2px solid currentColor;
line-height: 15px;
}

#work-navbar-item {
color: #3f3f3f;
line-height: 15px;
float:right;
margin-right: 40px;
z-index: 5;
line-height: 15px;
}

#about-navbar-item {
color: #3f3f3f;
line-height: 15px;
float:right;
margin-right: 0.1em;
z-index: 5;
}

#resume-navbar-item {
color: #3f3f3f;
line-height: 15px;
float:right;
margin-right: 0.1em;
z-index: 5;
}

最佳答案

可能与 display:flex 及其 order 属性。

#navbar {
width: 100%;
height: 100%;
font-family: 'Mukta', sans-serif;
display:flex;
justify-content:space-between;
}

.flex_right {
justify-content:flex-end;
display:flex;
margin-right:40px;
}

.navbar-item {
display: inline-block;
margin-top: 40px;
margin-left: 45px;
text-decoration: none;
padding-bottom: 3px;
transition: .2s linear;
color: #3f3f3f;
font-size: 18px;
}

.navbar-item: hover {
border-bottom: 1.5px solid currentColor;
cursor: pointer;
transition: .2s linear;
}

#current-navbar-item {
color: #3f3f3f;
border-bottom: 2px solid currentColor;
line-height: 15px;
}

#work-navbar-item {
color: #3f3f3f;
line-height: 15px;
z-index: 5;
line-height: 15px;
order:1; /* this is first */
}

#about-navbar-item {
color: #3f3f3f;
line-height: 15px;
z-index: 5;
order:2; /* this is second */
}

#resume-navbar-item {
color: #3f3f3f;
line-height: 15px;
float:right;
z-index: 5;
order:3; /* this is third */
}
<div class="page-wrapper">
<div class="home-page-wrapper">
<div id="navbar">
<div class="flex_left">
<a href="index.html" class="navbar-item" id="current-navbar-item" style="margin-left": 50px">Irene Li</a>
</div>
<div class="flex_right">
<a href="work.html" class="navbar-item" id="work-navbar-item" style="margin-right": 1000px">Work</a>
<a href="about.html" class="navbar-item" id="about-navbar-item" style="margin-right": 900px">About</a>
<a href="link" target="_blank" class="link navbar-item" id="resume-navbar-item" style="margin-right": 800px">Resume</a>
</div>
</div>

我使用 order 属性更改了订单。如您所见:

#navbar {
width: 100%;
height: 100%;
font-family: 'Mukta', sans-serif;
display:flex;
justify-content:space-between;
}

.flex_right {
justify-content:flex-end;
display:flex;
margin-right:40px;
}

.navbar-item {
display: inline-block;
margin-top: 40px;
margin-left: 45px;
text-decoration: none;
padding-bottom: 3px;
transition: .2s linear;
color: #3f3f3f;
font-size: 18px;
}

.navbar-item: hover {
border-bottom: 1.5px solid currentColor;
cursor: pointer;
transition: .2s linear;
}

#current-navbar-item {
color: #3f3f3f;
border-bottom: 2px solid currentColor;
line-height: 15px;
}

#work-navbar-item {
color: #3f3f3f;
line-height: 15px;
z-index: 5;
line-height: 15px;
order:3;
}

#about-navbar-item {
color: #3f3f3f;
line-height: 15px;
z-index: 5;
order:2;
}

#resume-navbar-item {
color: #3f3f3f;
line-height: 15px;
float:right;
z-index: 5;
order:1;
}
<div class="page-wrapper">
<div class="home-page-wrapper">
<div id="navbar">
<div class="flex_left">
<a href="index.html" class="navbar-item" id="current-navbar-item" style="margin-left": 50px">Irene Li</a>
</div>
<div class="flex_right">
<a href="work.html" class="navbar-item" id="work-navbar-item" style="margin-right": 1000px">Work</a>
<a href="about.html" class="navbar-item" id="about-navbar-item" style="margin-right": 900px">About</a>
<a href="link" target="_blank" class="link navbar-item" id="resume-navbar-item" style="margin-right": 800px">Resume</a>
</div>
</div>

关于html - 如何在 CSS 和 HTML 上安排文本的顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53981077/

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