Разбираемся в CSS
Anonymous
Почему не выравнивается текст:center; переместить мой класс = "текст 5" в центр?
Сообщение
Anonymous » 15 мар 2024, 22:17
Код: Выделить всё
Homepage
[*]
Header Logo
[list]
[url=index.html]header link one[/url]
[*][url=index.html]header link two[/url]
[*][url=index.html]header link three[/url]
[/list]
This website is awesome
This website has some subtext that goes here under the main title.It's a smaller font and the color is lower contrast
Sign up
this is a placeholder for an image
Some random information.
Copyright © The Odin Project 2023
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container {
width: 100%;
height: 45vh;
background-color: #1f2937;
position: static;
display: flex;
}
.footer {
position: absolute;
bottom: 0px;
width: 100%;
height: 10vh;
background-color: #1f2937;
color: white;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
}
.logo {
font-size: 24px;
font-family: 'Times New Roman', Times, serif;
color: white;
justify-content: space-between;
padding-top: 15px;
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
padding-left: 200px;
position: absolute;
top: 0;
}
.navbar {
color:white;
font-size: 18px;
position: fixed;
width: 85%;
top: 0;
right: 0;
margin: auto;
display: flex;
align-items: center;
justify-content: flex-end;
flex-direction: row;
padding-top: 15px;
padding-right: 330px;
}
.navbar ul li {
list-style: none;
display: inline-block;
margin: 0 20px;
text-decoration: none;
}
.text1 {
position: relative;
color: white;
padding-left: 200px;
font-size: 48px;
font-weight: bold;
width: 720px;
top: 100px;
}
.text2 {
position: relative;
color: white;
font-size: 18px;
width: 400px;
height: 200px;
top: 300px;
right: 520px;
}
.placeholder{
position: relative;
width: 500px;
height:250px;
background-color: grey;
border: 2px solid grey;
display:flex;
top: 100px;
right: 120px;
align-items: center;
justify-content: center;
color: white;
}
.button1{
border-radius: 5px;
position: relative;
display: flex;
font-weight: bold;
border: 2px solid #3882F6;
background-color:#3882F6;
height:40px;
width: 120px;
justify-content: center;
align-items: center;
}
.container2{
height: 45vh;
background-color: white;
position: relative;
padding-top: 30px;
display: flex;
flex-direction: row;
justify-content: space-evenly;
}
#text5{
font-size: 36px;
font-weight:800;
text-align: center;
}
#box1, #box2, #box3, #box4{
position: relative;
border: 2px solid #3882F6;
height: 100px;
width: 100px;
bottom: -100px;
right: 250px;
border-radius: 25px;
flex: 0 0 100px;
}
Почему class="text5" не перемещает текст к центру? На данный момент текст находится слева.
Я пробовал text- align=center, но это ни к чему не привело. Это связано с каскадированием? Я также попытался указать ширину и поля: 0 auto; это переместило текст, но не в центр, и испортило расстояние между ящиками.
Подробнее здесь:
https://stackoverflow.com/questions/781 ... the-center
1710530258
Anonymous
[code] Homepage [*] Header Logo [list] [url=index.html]header link one[/url] [*][url=index.html]header link two[/url] [*][url=index.html]header link three[/url] [/list] This website is awesome This website has some subtext that goes here under the main title.It's a smaller font and the color is lower contrast Sign up this is a placeholder for an image Some random information. Copyright © The Odin Project 2023 * { margin: 0; padding: 0; box-sizing: border-box; } .container { width: 100%; height: 45vh; background-color: #1f2937; position: static; display: flex; } .footer { position: absolute; bottom: 0px; width: 100%; height: 10vh; background-color: #1f2937; color: white; text-align: center; display: flex; justify-content: center; align-items: center; } .logo { font-size: 24px; font-family: 'Times New Roman', Times, serif; color: white; justify-content: space-between; padding-top: 15px; font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif; padding-left: 200px; position: absolute; top: 0; } .navbar { color:white; font-size: 18px; position: fixed; width: 85%; top: 0; right: 0; margin: auto; display: flex; align-items: center; justify-content: flex-end; flex-direction: row; padding-top: 15px; padding-right: 330px; } .navbar ul li { list-style: none; display: inline-block; margin: 0 20px; text-decoration: none; } .text1 { position: relative; color: white; padding-left: 200px; font-size: 48px; font-weight: bold; width: 720px; top: 100px; } .text2 { position: relative; color: white; font-size: 18px; width: 400px; height: 200px; top: 300px; right: 520px; } .placeholder{ position: relative; width: 500px; height:250px; background-color: grey; border: 2px solid grey; display:flex; top: 100px; right: 120px; align-items: center; justify-content: center; color: white; } .button1{ border-radius: 5px; position: relative; display: flex; font-weight: bold; border: 2px solid #3882F6; background-color:#3882F6; height:40px; width: 120px; justify-content: center; align-items: center; } .container2{ height: 45vh; background-color: white; position: relative; padding-top: 30px; display: flex; flex-direction: row; justify-content: space-evenly; } #text5{ font-size: 36px; font-weight:800; text-align: center; } #box1, #box2, #box3, #box4{ position: relative; border: 2px solid #3882F6; height: 100px; width: 100px; bottom: -100px; right: 250px; border-radius: 25px; flex: 0 0 100px; } [/code] Почему class="text5" не перемещает текст к центру? На данный момент текст находится слева. Я пробовал text- align=center, но это ни к чему не привело. Это связано с каскадированием? Я также попытался указать ширину и поля: 0 auto; это переместило текст, но не в центр, и испортило расстояние между ящиками. Подробнее здесь: [url]https://stackoverflow.com/questions/78169171/why-doesnt-text-aligncenter-move-my-class-text5-to-the-center[/url]
0 Ответы
15 Просмотры
Последнее сообщение Anonymous
26 ноя 2024, 18:57
Центр выравнивается с настольной клетками
Anonymous »
24 янв 2025, 03:20 » в форуме
Html
Я пытаюсь использовать способ ячейки таблицы для центрирования элемента div по вертикали и горизонтали.
Это работает, когда я использую следующий код:
div {
display: table;
}
.logo {
display: table-cell;
position: absolute;
vertical-align: middle;...
0 Ответы
16 Просмотры
Последнее сообщение Anonymous
24 янв 2025, 03:20
Центр выравнивается с настольной клетками
Anonymous »
09 апр 2025, 22:11 » в форуме
Html
Я пытаюсь использовать табличный способ сосредоточиться на вертикальном и горизонтали. div {
display: table;
}
.logo {
display: table-cell;
position: absolute;
vertical-align: middle;
left: 0;
right: 0;
bottom: 0;
top: 0;
margin: auto;
}
Но я бы...
0 Ответы
10 Просмотры
Последнее сообщение Anonymous
09 апр 2025, 22:11
Центр выравнивается с настольной клетками
Anonymous »
09 апр 2025, 22:11 » в форуме
CSS
Я пытаюсь использовать табличный способ сосредоточиться на вертикальном и горизонтали. div {
display: table;
}
.logo {
display: table-cell;
position: absolute;
vertical-align: middle;
left: 0;
right: 0;
bottom: 0;
top: 0;
margin: auto;
}
Но я бы...
0 Ответы
31 Просмотры
Последнее сообщение Anonymous
09 апр 2025, 22:11
Центр выравнивается с настольной клетками
Anonymous »
09 апр 2025, 23:25 » в форуме
Html
Я пытаюсь использовать табличный способ сосредоточиться на вертикальном и горизонтали. div {
display: table;
}
.logo {
display: table-cell;
position: absolute;
vertical-align: middle;
left: 0;
right: 0;
bottom: 0;
top: 0;
margin: auto;
}
Но я бы...
0 Ответы
9 Просмотры
Последнее сообщение Anonymous
09 апр 2025, 23:25