【发布时间】:2022-02-07 22:03:10
【问题描述】:
我尝试做一些 CSS,我有 4 个项目在一行中。
我想对齐我的 2 个“sous-jacent de référence”,但我不知道该怎么做。
我尝试使用position: relative,但没有用
这是我的代码:
body {
background-color: rgb(0, 0, 0);
text-align: center;
}
.title {
color: white;
border: 2px solid black;
margin: 2%;
padding-bottom: 2%;
}
.left {
padding-left: 2%;
float: left;
color: white;
font-size: 20px;
padding-top: 2%;
}
.left2 {
padding-left: 2%;
float: left;
color: white;
font-size: 20px;
padding-top: 2%;
}
.left3 {
color: white;
font-size: 20px;
padding-top: 2%;
position: absolute;
}
.right {
float: left;
padding-left: 30%;
color: white;
font-size: 20px;
padding-top: 2%;
}
.right2 {
float: left;
padding-left: 30%;
color: white;
font-size: 20px;
padding-top: 2%;
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div class="title">
<h2>Formulaire</h2>
</div>
<div class="left">
typologie du produit
</div>
<div class="left2">
<input type="text" id="typologie" name="typologie" required minlength="2" maxlength="50" size="10"> </div>
<div class="right">
Sous-jacent de référence
</div>
<div class="left2">
<input type="text" id="Sous-jacent" name="Sous-jacent" required minlength="2" maxlength="50" size="10"> </div>
<div class="left">
Nom du produit
</div>
<div class="left2">
<input type="text" id="typologie" name="typologi2" required minlength="2" maxlength="50" size="10"> </div>
<div class="right">
Sous-jacent de référence
</div>
<div class="left2">
<input type="text" id="Sous-jacent" name="Sous-jacent2" required minlength="2" maxlength="50" size="10"> </div>
</body>
</html>
我想对我的算法说:“我的 3 和 div 从 x% 开始”
我尝试了很多东西(当我使用 float: right 时它可以工作,但它很混乱)
感谢您的帮助!
【问题讨论】:
-
可以调整 HTML 代码,还是只能通过 CSS 来完成?
-
是的,我可以像 Css 一样调整 Html
-
CSS-Grid 或 Flexbox。 绝对不使用
float。