I've created a list of items that are rotated. Everything is rolling except for long strings... For an unknown reason, the "long items" gets pushed below the green alignment stroke.
I may see 2 cases here depending on whether the string contains spaces or not (item B vs item C.
I've tried to play with vertical-align, then flexbox without success. if you have ideas, I'll take them gracefully.
Thank you so much.
ol {
margin-top: 8rem;
transform: translate(0%, -50%);
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
width: 100%;
padding-left: 0px;
}
li {
position: relative;
text-decoration: none;
list-style-type: none;
width: 20px;
height: 20px;
border: 5px solid rgb(201, 201, 201);
border-radius: 100%;
display: inline-block;
margin-right: 20px;
box-sizing: content-box;
}
li::before {
content: "";
display: block;
width: 25px;
height: 5px;
margin-left: 25px;
margin-top: 7px;
background-color: rgb(220, 221, 221);
}
li:last-child::before {
display: none;
}
li:last-child {
margin-right: 0;
}
li span {
position: absolute;
top: -75px;
left: -25px;
color: #000;
transform: rotate(-70deg);
width: 120px;
text-decoration: none;
}
li.checked {
background-color: #27a2b8;
border-color: rgb(20, 25, 10);
}
.checkbox {
position: absolute;
top: -2px;
left: -2px;
}
.checkbox>input {
position: absolute;
clip: rect(0px, 0px, 0px, 0px);
}
.checkbox>svg>circle {
stroke-width: 6px;
}
.checkbox .checked>svg {
background-color: rgb(0, 175, 245);
border-radius: 50%;
}
.checkbox .checked>svg>path {
stroke: rgb(255, 255, 255);
}
}
<ol>
<li ><span >Item A is OK</span>
<div >
<input type="checkbox" name="itemA">
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24">
<path d="M6.5 12.5l4 4 8-8" fill="none" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" ></path>
</svg>
</div>
</li>
<li >
<span >Item B is really too long</span>
<div name="itemB">
<input type="checkbox" checked>
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24">
<path d="M6.5 12.5l4 4 8-8" fill="none" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" ></path>
</svg>
</div>
</li>
<li >
<span >Item-c-is-also-really-too-long-too</span>
<div name="itemC">
<input type="checkbox" checked>
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24">
<path d="M6.5 12.5l4 4 8-8" fill="none" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" ></path>
</svg>
</div>
</li>
<li >
<span >Item c is OK</span>
<div name="itemD">
<input type="checkbox">
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24">
<path d="M6.5 12.5l4 4 8-8" fill="none" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" ></path>
</svg>
</div>
</li>
</ol>
CodePudding user response:
Use white-space: nowrap on your li span, this should fix it.
Here is the modified snippet:
ol {
margin-top: 8rem;
transform: translate(0%, -50%);
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
width: 100%;
padding-left: 0px;
}
li {
position: relative;
text-decoration: none;
list-style-type: none;
width: 20px;
height: 20px;
border: 5px solid rgb(201, 201, 201);
border-radius: 100%;
display: inline-block;
margin-right: 20px;
box-sizing: content-box;
}
li::before {
content: "";
display: block;
width: 25px;
height: 5px;
margin-left: 25px;
margin-top: 7px;
background-color: rgb(220, 221, 221);
}
li:last-child::before {
display: none;
}
li:last-child {
margin-right: 0;
}
li span {
position: absolute;
top: -75px;
left: -25px;
color: #000;
transform: rotate(-70deg);
width: 120px;
text-decoration: none;
white-space: nowrap;
}
li.checked {
background-color: #27a2b8;
border-color: rgb(20, 25, 10);
}
.checkbox {
position: absolute;
top: -2px;
left: -2px;
}
.checkbox>input {
position: absolute;
clip: rect(0px, 0px, 0px, 0px);
}
.checkbox>svg>circle {
stroke-width: 6px;
}
.checkbox .checked>svg {
background-color: rgb(0, 175, 245);
border-radius: 50%;
}
.checkbox .checked>svg>path {
stroke: rgb(255, 255, 255);
}
}
<ol>
<li ><span >Item A is OK</span>
<div >
<input type="checkbox" name="itemA">
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24">
<path d="M6.5 12.5l4 4 8-8" fill="none" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" ></path>
</svg>
</div>
</li>
<li >
<span >Item B is really too long</span>
<div name="itemB">
<input type="checkbox" checked>
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24">
<path d="M6.5 12.5l4 4 8-8" fill="none" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" ></path>
</svg>
</div>
</li>
<li >
<span >Item-c-is-also-really-too-long-too</span>
<div name="itemC">
<input type="checkbox" checked>
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24">
<path d="M6.5 12.5l4 4 8-8" fill="none" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" ></path>
</svg>
</div>
</li>
<li >
<span >Item c is OK</span>
<div name="itemD">
<input type="checkbox">
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24">
<path d="M6.5 12.5l4 4 8-8" fill="none" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" ></path>
</svg>
</div>
</li>
</ol>
CodePudding user response:
I made some changes in the html and css file and reached this result. Hopefully it benefits your business. I put the text in a div and added the p tag. I made some minor changes in css and used overflow-wrap:break-word
ol {
margin-top: 8rem;
transform: translate(0%, -50%);
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
width: 100%;
padding-left: 0px;
}
li {
position: relative;
text-decoration: none;
list-style-type: none;
width: 20px;
height: 20px;
border: 5px solid rgb(201, 201, 201);
border-radius: 100%;
display: inline-block;
margin-right: 40px;
box-sizing: content-box;
}
li::before {
content: "";
display: block;
width: 40px;
height: 5px;
margin-left: 25px;
margin-top: 7px;
background-color: rgb(220, 221, 221);
}
li:last-child::before {
display: none;
}
li p {
top: -100px;
left: -20px;
position: absolute;
color: #000;
transform: rotate(-70deg);
width: 120px;
text-decoration: none;
display: inline-block;
overflow-wrap: break-word;
}
li span {
top: -77px;
left: -22px;
position: absolute;
color: #000;
transform: rotate(-70deg);
width: 120px;
text-decoration: none;
display: inline-block;
overflow-wrap: break-word;
}
li.checked {
background-color: #27a2b8;
border-color: rgb(20, 25, 10);
}
.checkbox {
position: relative;
top: -2px;
left: -2px;
}
.checkbox > input {
position: absolute;
clip: rect(0px, 0px, 0px, 0px);
}
.checkbox > svg > circle {
stroke-width: 6px;
}
.checkbox .checked > svg {
background-color: rgb(0, 175, 245);
border-radius: 50%;
}
.checkbox .checked > svg > path {
stroke: rgb(255, 255, 255);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/style.css">
<title>Document</title>
</head>
<body>
<div id="container">
<ol>
<li >
<div style="text-align: left;">
<span style="padding:-3px;">Item A is OK</span>
<div>
<div name="itemB">
<input type="checkbox" checked>
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24">
<path d="M6.5 12.5l4 4 8-8" fill="none" stroke-width="1" stroke-linecap="round"
stroke-linejoin="round" stroke-miterlimit="10" ></path>
</svg>
</div>
</li>
<li >
<div style="text-align: left;">
<p>B is really too long</p>
<div>
<div name="itemB">
<input type="checkbox" checked>
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24">
<path d="M6.5 12.5l4 4 8-8" fill="none" stroke-width="1" stroke-linecap="round"
stroke-linejoin="round" stroke-miterlimit="10" ></path>
</svg>
</div>
</li>
<li >
<div style="text-align: center;">
<p>Item-C-is-also-really-too-long-too</p>
<div>
<div name="itemB">
<input type="checkbox" checked>
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24">
<path d="M6.5 12.5l4 4 8-8" fill="none" stroke-width="1" stroke-linecap="round"
stroke-linejoin="round" stroke-miterlimit="10" ></path>
</svg>
</div>
</li>
<li >
<div style="text-align: left;">
<span>Item D is OK</span>
<div>
<div name="itemB">
<input type="checkbox" checked>
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24">
<path d="M6.5 12.5l4 4 8-8" fill="none" stroke-width="1" stroke-linecap="round"
stroke-linejoin="round" stroke-miterlimit="10" ></path>
</svg>
</div>
</li>
</ol>
</div>
</body>
</html>
CodePudding user response:
I have one more solution, see your updated code. It work with left aligned text and fixed text width.
You can also check Codepen.io example.
:root {
--ol-gap-size: 20px;
}
ol {
margin-top: 8rem;
transform: translate(0%, -50%);
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
width: 100%;
padding-left: 0;
column-gap: var(--ol-gap-size);
}
li {
position: relative;
text-decoration: none;
list-style-type: none;
width: 20px;
height: 20px;
border: 5px solid rgb(201, 201, 201);
border-radius: 50%;
/* display: inline-block; */
/* margin-right: 20px; */
/* box-sizing: content-box; */
}
li:not(:last-child):before {
content: "";
display: block;
width: calc(var(--ol-gap-size) 5px);
height: 5px;
margin-left: 25px;
margin-top: 7px;
background-color: rgb(220, 221, 221);
}
/* li:last-child::before {
display: none;
} */
/* li:last-child {
margin-right: 0;
} */
li span {
position: absolute;
color: #000;
width: 120px;
text-decoration: none;
top: 50%;
left: calc(100% 10px);
transform: translate3d(0, -50%, 0) rotate(-70deg);
transform-origin: calc(var(--ol-gap-size) * -1) center;
/* top: -75px; */
/* left: -25px; */
/* transform: rotate(-70deg); */
}
li.checked {
background-color: #27a2b8;
border-color: rgb(20, 25, 10);
}
.checkbox {
position: absolute;
top: -2px;
left: -2px;
}
.checkbox>input {
position: absolute;
clip: rect(0px, 0px, 0px, 0px);
}
.checkbox>svg>circle {
stroke-width: 6px;
}
.checkbox .checked>svg {
background-color: rgb(0, 175, 245);
border-radius: 50%;
}
.checkbox .checked>svg>path {
stroke: rgb(255, 255, 255);
}
<ol>
<li ><span >Item A is OK</span>
<div >
<input type="checkbox" name="itemA">
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24">
<path d="M6.5 12.5l4 4 8-8" fill="none" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" ></path>
</svg>
</div>
</li>
<li >
<span >Item B is really too long</span>
<div name="itemB">
<input type="checkbox" checked>
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24">
<path d="M6.5 12.5l4 4 8-8" fill="none" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" ></path>
</svg>
</div>
</li>
<li >
<span >Item-c-is-also-really-too-long-too</span>
<div name="itemC">
<input type="checkbox" checked>
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24">
<path d="M6.5 12.5l4 4 8-8" fill="none" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" ></path>
</svg>
</div>
</li>
<li >
<span >Item c is OK</span>
<div name="itemD">
<input type="checkbox">
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24">
<path d="M6.5 12.5l4 4 8-8" fill="none" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" ></path>
</svg>
</div>
</li>
</ol>

