Я разрабатываю элемент списка, все работает нормально, но столкнулся с проблемой установки ширины дочернего элемента больше, чем ширина родителя с позиционированием absolute
. Вот код, который я когда-либо делал
.container {
margin: 5rem;
}
.listing {
width: 50px;
height: 50px;
background-color: #333C83;
clip-path: polygon(25% 5%, 100% 0%, 75% 95%, 0% 100%);
display: flex;
justify-content: center;
align-items: center;
}
.circle {
width: 25px;
height: 25px;
border-radius: 50%;
background-color: #0A0D1E;
display: flex;
justify-content: center;
align-items: center;
}
.secondaryCircle {
width: 15px;
height: 15px;
border-radius: 50%;
background-color: #FABC42;
position: relative;
}
.line {
height: 5px;
background-color: #FABC42;
width: 40px;
position: absolute;
top: 4.5px;
left: 14px;
}
<div class = "container">
<div class = "listing">
<div class = "circle">
<div class = "secondaryCircle">
<div class = "line"></div>
</div>
</div>
</div>
</div>
Как видите, линия шириной 40px
не видна. Как я могу это исправить ?
Вот результат, который я хотел
@FatemehAzizkhani понял
Это из-за этого css в классе .listing
.listing { clip-path: polygon(25% 5%, 100% 0%, 75% 95%, 0% 100%); }
Он имеет тенденцию обрезать края ваших коробок. Попробуйте использовать transform:skew
для достижения той конкретной цели, которую вы хотите иметь.
Я привел пример. Не стесняйтесь настраивать его со своей стороны.
.container {
margin: 5rem;
}
.listing {
width: 40px;
height: 50px;
background-color: #333C83;
transform: skewY(-12deg);
display: flex;
justify-content: center;
align-items: center;
}
.circle {
width: 25px;
height: 25px;
border-radius: 50%;
background-color: #0A0D1E;
display: flex;
justify-content: center;
align-items: center;
transform: skewY(12deg);
}
.secondaryCircle {
width: 15px;
height: 15px;
border-radius: 50%;
background-color: #FABC42;
position: relative;
}
.line {
height: 5px;
background-color: #FABC42;
width: 40px;
position: absolute;
top: 4.5px;
left: 14px;
}
<div class = "container">
<div class = "listing">
<div class = "circle">
<div class = "secondaryCircle">
<div class = "line"></div>
</div>
</div>
</div>
</div>