Как сделать так, чтобы мой основной класс находился рядом с второстепенным классом? Потому что в результате мой основной класс находится ниже стороннего класса, и я не знаю, как это понять.
Это код:
aside {
height: 100vh;
width: 350px;
justify-content: space-between;
flex-direction: column;
}
aside ul {
padding-top: 30%;
list-style-type: none;
text-align: center;
}
aside a {
text-decoration: none;
display: inline-block;
font-size: 23px;
color: $color5;
margin: 40px;
font-family: $font1;
font-weight: lighter;
}
aside a:hover {
color: $color1;
}
<aside>
<ul>
<li><a href = "#PersonalInformation">Personal Information</a></li>
<li class = "second"><a href = "#SecurityandLogin">Security and Login</a></li>
<li><a href = "Logout">Logout</a></li>
</ul>
</aside>
<main>
<h4>To keep you safe and secure</h4>
</main>
Вы можете либо попробовать с float left, либо вы можете обернуть «aside» и «main» внутри div и использовать display flex. Дай мне знать, если тебе еще понадобится помощь.
В таких сценариях вы бы хотели использовать flexbox
или css grid
, например:
.container {
display: grid;
grid-template-columns: 350px 1fr;
gap: 1rem;
}
aside {
min-height: 100vh;
justify-content: space-between;
flex-direction: column;
border-right: 1px solid red;
}
aside ul {
padding-top: 30%;
list-style-type: none;
text-align: center;
}
aside a {
text-decoration: none;
display: inline-block;
font-size: 23px;
color: $color5;
margin: 40px;
font-family: $font1;
font-weight: lighter;
}
aside a:hover {
color: $color1;
}
<div class = "container">
<aside>
<ul>
<li><a href = "#PersonalInformation">Personal Information</a></li>
<li class = "second"><a href = "#SecurityandLogin">Security and Login</a></li>
<li><a href = "Logout">Logout</a></li>
</ul>
</aside>
<main>
<h4>To keep you safe and secure</h4>
</main>
</div>
Рад, что смог помочь. Вы можете просто использовать border-right
на aside
. Я отредактировал свой ответ, посмотрите, пожалуйста.
Я также предлагаю вам следить за Кевин Пауэлл на YouTube и время от времени смотреть его предыдущие видео, если вы еще этого не сделали. Вы узнаете так много о css.
Вы можете сделать это, используя следующее:
display: inline-block;
grid
в родительском классе.display: flex;
с помощью flex-direction: row;
Например, (Используя встроенный блок):
aside,
main {
display: inline-block;
vertical-align: middle;
border: 1px solid blue;
}
aside {
height: 100vh;
width: 350px;
justify-content: space-between;
flex-direction: column;
}
aside ul {
padding-top: 30%;
list-style-type: none;
text-align: center;
}
aside a {
text-decoration: none;
display: inline-block;
font-size: 23px;
color: $color5;
margin: 40px;
font-family: $font1;
font-weight: lighter;
}
aside a:hover {
color: $color1;
}
<div>
<aside>
<ul>
<li><a href = "#PersonalInformation">Personal Information</a></li>
<li class = "second"><a href = "#SecurityandLogin">Security and Login</a></li>
<li><a href = "Logout">Logout</a></li>
</ul>
</aside>
<main>
<h4>To keep you safe and secure</h4>
</main>
</div>
Например, (Используя флекс):
div {
display: flex;
flex-direction: row;
align-items: center;
}
main, aside {
border: 1px solid blue;
}
aside {
height: 100vh;
width: 350px;
justify-content: space-between;
flex-direction: column;
}
aside ul {
padding-top: 30%;
list-style-type: none;
text-align: center;
}
aside a {
text-decoration: none;
display: inline-block;
font-size: 23px;
color: $color5;
margin: 40px;
font-family: $font1;
font-weight: lighter;
}
aside a:hover {
color: $color1;
}
<div>
<aside>
<ul>
<li><a href = "#PersonalInformation">Personal Information</a></li>
<li class = "second"><a href = "#SecurityandLogin">Security and Login</a></li>
<li><a href = "Logout">Logout</a></li>
</ul>
</aside>
<main>
<h4>To keep you safe and secure</h4>
</main>
</div>
Например, (с использованием сетки):
div {
display: grid;
grid-template-columns: 350px 1fr;
gap: 1rem;
}
aside,
main {
border: 1px solid blue;
}
aside {
height: 100vh;
width: 350px;
justify-content: space-between;
flex-direction: column;
}
aside ul {
padding-top: 30%;
list-style-type: none;
text-align: center;
}
aside a {
text-decoration: none;
display: inline-block;
font-size: 23px;
color: $color5;
margin: 40px;
font-family: $font1;
font-weight: lighter;
}
aside a:hover {
color: $color1;
}
<div>
<aside>
<ul>
<li><a href = "#PersonalInformation">Personal Information</a></li>
<li class = "second"><a href = "#SecurityandLogin">Security and Login</a></li>
<li><a href = "Logout">Logout</a></li>
</ul>
</aside>
<main>
<h4>To keep you safe and secure</h4>
</main>
</div>
Спасибо, сэр! Последний вопрос, как я могу добавить вертикальную линию между основным и боковым классом?