How do I adjust this custom <li> content as intended - html

Above is a mockup of the content that I am trying to replicate.
Here is what I have right now:
below are my <ul> and <li> with CSS but I cannot exactly replicate what is in the mockup even if I use padding or margin:
ul {
padding: 0;
list-style: none;
}
#b1::before {
content: "• ";
color: #B1B1B1;
}
#b2::before {
content: '|';
color: #B1B1B1;
margin-bottom: 20px;
}
<ul>
<li id="b1">Introduction</li>
<li id="b2"></li>
<li id="b1">Disclaimers</li>
<li id="b2"></li>
<li id="b1">Preservation of Immunities</li>
<li id="b2"></li>
<li id="b1">General</li>
</ul>
looking for another way to edit the CSS that is not padding or margin to get the design I need. Any help would be appreciated.

#import "https://cdn.jsdelivr.net/gh/KunalTanwar/normalize/css/normalize.inter.min.css";
body {
height: 100%;
display: grid;
place-items: center;
}
ul {
display: flex;
row-gap: 16px;
flex-direction: column;
}
li {
display: flex;
line-height: 1;
padding-left: 8px;
align-items: center;
}
li::before {
content: "";
position: absolute;
left: -12px;
width: 8px;
height: 8px;
border-radius: 50%;
aspect-ratio: 1/1;
background-color: gray;
box-shadow: 0 0 0 2px white;
}
li:not(:last-child)::after {
content: "";
z-index: -1;
position: absolute;
top: calc(100% - 6px);
left: -8px;
width: 1px;
height: 32px;
background-color: #CCCCCC;
}
<ul>
<li id="b1">Introduction</li>
<li id="b1">Disclaimers</li>
<li id="b1">Preservation of Immunities</li>
<li id="b1">General</li>
</ul>

Related

How to create branches for blocks using pseudo elements?

I am trying to create a simple structure of blocks using only HTML and CSS. In the center I have one main block from which other blocks branch off to the left and right.
All of them should be connected by lines to other blocks, but how to create these lines is a question...
I have some code:
.chapter {
display: flex;
align-items: center;
justify-content: center;
max-width: 900px;
margin: 0 auto;
padding: 0;
gap: 2rem;
}
.main {
position: relative;
padding: 1rem 2rem;
background-color: rgb(224, 224, 224);
border: 1px solid black;
}
.main::before,
.main::after {
content: "";
position: absolute;
top: 50%;
display: block;
width: 1rem;
height: 1px;
background-color: #000;
}
.main::before {
left: -1rem;
}
.main::after {
right: -1rem;
}
.right,
.left {
list-style-type: none;
margin: 0;
padding: 0;
}
.elem {
position: relative;
padding: 0.3rem 2rem;
background-color: rgb(224, 224, 224);
border: 1px solid black;
margin-bottom: 0.5rem;
}
.elem:last-child {
margin-bottom: 0px;
}
.elem::after {
content: "";
position: absolute;
top: 50%;
display: block;
width: 1rem;
height: 1px;
background-color: #000;
}
.left>.elem::after {
right: -1rem;
}
.right>.elem::after {
left: -1rem;
}
<div class="chapter">
<ul class="left">
<li class="elem">elem</li>
<li class="elem">elem</li>
<li class="elem">elem</li>
<li class="elem">elem</li>
<li class="elem">elem</li>
</ul>
<div class="main">root</div>
<ul class="right">
<li class="elem">elem</li>
<li class="elem">elem</li>
<li class="elem">elem</li>
<li class="elem">elem</li>
<li class="elem">elem</li>
</ul>
</div>
And what I get and what I want:
Is it possible to achieve this arrangement of lines?
Or perhaps there is another more elegant way to do it?

How do I align the bullets to middle in a <li> tag?

So I want to create a bar like that. I found a code about it and I modified it a little bit, originally it was a timeline. So my problem is that I can't align the bullets to middle in the li tag. How could I achive that?
ul.language-bar {
max-width: 29em;
width: 100%;
padding: 0 18px;
height: 2em;
margin: 0;
padding: 0;
font-size: 10px;
/* change font size only to scale*/
}
ul.language-bar li {
width: 15%;
float: left;
height: 100%;
list-style: none;
position: relative;
margin: 0;
}
ul.language-bar li.empty:before {
background: #fff;
border: 0.3em solid #f98d9c;
box-sizing: border-box;
}
ul.language-bar li:before {
content: '';
display: block;
position: absolute;
left: 0;
top: 0;
background: #f98d9c;
width: 2em;
height: 2em;
border-radius: 2em;
z-index: 2;
}
.language-container .language-bar {
justify-content: center;
display: flex;
}
<div class="language-container">
<ul class="language-bar">
<li></li>
<li></li>
<li></li>
<li class="empty"></li>
<li class="empty"></li>
</ul>
</div>
You need to add these three lines to your ul.language-bar li:before class
position: absolute;
left: 50%;
margin-left: -1em;
This will
unbind bullets to make it possible to position them directly
move every bullet to the center of its parent li (since it is the first parent element having positions:relative)
shift every bullet 1em (half of bullet's width) to the left to make it perfectly centred.
ul.language-bar {
max-width: 29em;
width: 100%;
padding: 0 18px;
height: 2em;
margin: 0;
padding: 0;
font-size: 10px;
/* change font size only to scale*/
}
ul.language-bar li {
width: 15%;
float: left;
height: 100%;
list-style: none;
position: relative;
margin: 0;
}
ul.language-bar li.empty:before {
background: #fff;
border: 0.3em solid #f98d9c;
box-sizing: border-box;
}
ul.language-bar li:before {
content: '';
display: block;
position: absolute;
left: 0;
top: 0;
background: #f98d9c;
width: 2em;
height: 2em;
border-radius: 2em;
z-index: 2;
position: absolute;
left: 50%;
margin-left: -1em;
}
.language-container .language-bar {
justify-content: center;
display: flex;
}
<div class="language-container">
<ul class="language-bar">
<li></li>
<li></li>
<li></li>
<li class="empty"></li>
<li class="empty"></li>
</ul>
</div>
By not trying to center an absolutely positioned pseudo element, like you're currently doing.
You will have to nest a block element inside of the li element and center that.
Like so:
ul.language-bar {
max-width: 29em;
width: 100%;
padding: 0 18px;
height: 2em;
margin: 0;
padding: 0;
font-size: 10px;
/* change font size only to scale*/
}
ul.language-bar li {
width: 15%;
float: left;
height: 100%;
list-style: none;
position: relative;
margin: 0;
}
ul.language-bar li.empty span {
content: '';
display: block;
position: relative;
margin: 0 auto;
background: #fff;
border: 0.3em solid #f98d9c;
box-sizing: border-box;
width: 2em;
height: 2em;
border-radius: 2em;
z-index: 2;
}
ul.language-bar li span {
content: '';
display: block;
position: relative;
margin: 0 auto;
background: #f98d9c;
width: 2em;
height: 2em;
border-radius: 2em;
z-index: 2;
}
.language-container .language-bar {
justify-content: center;
display: flex;
}
<div class="language-container">
<ul class="language-bar">
<li><span></span></li>
<li><span></span></li>
<li><span></span></li>
<li class="empty"><span></span></li>
<li class="empty"><span></span></li>
</ul>
</div>
This is obviously quick and dirty to illustrate the point and would need to be optimized.
Another possibility would be to use Flexbox for the layout. Still, it needs a separate element inside of the li elements to work.
With some changes for a shorter CSS...
:root {
--scale: 20px;
}
.language-container {
display: table;
margin: 0 auto;
}
.language-container ul {
list-style : none;
font-size : var(--scale);
}
.language-container ul li {
display: inline-block;
position: relative;
background: #f98d9b;
width: 2em;
height: 2em;
border-radius: 2em;
}
.language-container ul li.empty:after {
position: absolute;
left: 0.3em;
top: 0.3em;
content: '';
display: block;
width: 1.4em;
height: 1.4em;
border-radius: 1.4em;
box-sizing: border-box;
background: #fff;
}
<div class="language-container">
<ul>
<li></li>
<li></li>
<li></li>
<li class="empty"></li>
<li class="empty"></li>
</ul>
</div>

Is it possible to make these arrows with html and css?

I am trying to use HTML and CSS instead of images to show some arrows -- Here is the image:
I'm trying to make these arrows with before and after pseudo-elements, but I have got problems.
Here's my code:
HTML:
<ul class="steps-list">
<li class="step-item">
Contact us
</li>
<li class="step-item">
Consult with RCIC
</li>
<li class="step-item">
Apply via your pathway
</li>
<li class="step-item">
Settle in Canada
</li>
</ul>
SASS:
.steps-list {
display: flex;
.step-item {
display: inline-block;
text-align: center;
width: 25%;
.step-link {
font-weight: bold;
background: #e2e3e4;
width: 100%;
display: inline-block;
padding: 2rem 1rem;
&:hover {
#include gradient(left, $gradientList2);
}
}
}
}
I have followed this article by the way:
https://css-tricks.com/snippets/css/css-triangle/
[Edit] After looking at your image again, I failed to account for the first element being flat. I have updated my answer.
Using before,after, and nth-child selectors, you can achieve what you showed in your image. The before and after pseudo elements are used to create the top and bottom half of the arrows while the nth-child selectors are used to make the arrows appear to be progressively closer together.
.steps-list {
display: flex;
list-style: none;
}
.steps-list .step-item {
position: relative;
display: flex;
align-items:center;
text-align: center;
width: 25%;
}
.steps-list .step-item .step-link {
font-weight: bold;
width: 100%;
display: inline-block;
padding:10px 5px;
box-sizing:border-box;
}
.step-link::before {
content: "";
display: block;
position: absolute;
transform: skew(-40deg, 0);
background: #e2e3e4;
height: 50%;
bottom: 0;
z-index: -1;
left:5px;
}
.step-link::after {
content: "";
display: block;
position: absolute;
transform: skew(40deg, 0);
background: #e2e3e4;
height: 50%;
top: 0;
z-index: -1;
left:5px;
}
.step-item:nth-child(1){
overflow:hidden;
}
.step-item:nth-child(1) .step-link::after {
width:95%;
left:-15px;
}
.step-item:nth-child(1) .step-link::before {
width: 95%;
left:-15px;
}
.step-item:nth-child(2) .step-link::after {
width: 90%;
}
.step-item:nth-child(2) .step-link::before {
width: 90%;
}
.step-item:nth-child(3) .step-link::after {
width: 95%;
}
.step-item:nth-child(3) .step-link::before {
width: 95%;
}
.step-item:nth-child(4) .step-link::after {
width: 100%;
}
.step-item:nth-child(4) .step-link::before {
width: 100%;
}
<ul class="steps-list">
<li class="step-item">
Contact us
</li>
<li class="step-item">
Consult with RCIC
</li>
<li class="step-item">
Apply via your pathway
</li>
<li class="step-item">
Settle in Canada
</li>
</ul>
Check this site
.clearfix:after {
clear: both;
content: "";
display: block;
height: 0;
}
.container {
font-family: 'Lato', sans-serif;
width: 1000px;
margin: 0 auto;
}
.wrapper {
display: table-cell;
height: 400px;
vertical-align: middle;
}
.nav {
margin-top: 40px;
}
.arrow-steps .step {
font-size: 14px;
text-align: center;
color: #666;
cursor: default;
margin: 0 3px;
padding: 10px 10px 10px 30px;
min-width: 180px;
float: left;
position: relative;
background-color: #d9e3f7;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
transition: background-color 0.2s ease;
}
.arrow-steps .step:after,
.arrow-steps .step:before {
content: " ";
position: absolute;
top: 0;
right: -17px;
width: 0;
height: 0;
border-top: 19px solid transparent;
border-bottom: 17px solid transparent;
border-left: 17px solid #d9e3f7;
z-index: 2;
transition: border-color 0.2s ease;
}
.arrow-steps .step:before {
right: auto;
left: 0;
border-left: 17px solid #fff;
z-index: 0;
}
.arrow-steps .step:first-child:before {
border: none;
}
.arrow-steps .step:first-child {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.arrow-steps .step span {
position: relative;
}
<div class="container">
<div class="wrapper">
<div class="arrow-steps clearfix">
<div class="step current"> <span> Step 1</span> </div>
<div class="step"> <span>Step 2 some words</span> </div>
<div class="step"> <span> Step 3</span> </div>
<div class="step"> <span>Step 4</span> </div>
</div>
</div>
</div>

Using css calc() with step

We have used a pure css base progress bar.
The main css part is as below.
.container {
width: 600px;
margin: 20px auto;
}
.progressbar {
margin: 0;
padding: 0;
counter-reset: step;
}
.progressbar li {
list-style-type: none;
width: 25%;
float: left;
font-size: 12px;
position: relative;
text-align: center;
text-transform: uppercase;
color: #7d7d7d;
}
.progressbar li:before {
width: 30px;
height: 30px;
content: counter(step);
counter-increment: step;
line-height: 30px;
border: 2px solid #7d7d7d;
display: block;
text-align: center;
margin: 0 auto 10px auto;
border-radius: 50%;
background-color: white;
}
.progressbar li:after {
width: 100%;
height: 2px;
content: '';
position: absolute;
background-color: #7d7d7d;
top: 15px;
left: -50%;
z-index: -1;
}
...............
The html
<div class="container">
<ul class="progressbar">
<li class="active">login</li>
<li>choose interest</li>
........
Complete sample could be found at https://jsfiddle.net/wbj7e79p/.
As you can see it mess up for seven step. The reason is .progressbar li width which is fixed to 25% we wanted to make it dynamic base on number of steps.
So we tried width : calc (100% / steps) or calc (100% / counter(steps)) but none of them worked. Any idea !
Please consider that we are building a component which build a progress bar on the fly, so we can not find the actual number of steps
Did you consider flexbox?
body {
font-family: 'Alegreya Sans', sans-serif;
margin: 0;
padding: 0;
}
.container {
margin: 20px auto;
}
.progressbar {
margin: 0;
padding: 0;
counter-reset: step;
display: flex;
}
.progressbar li {
list-style-type: none;
flex: 1;
font-size: 12px;
position: relative;
text-align: center;
text-transform: uppercase;
color: #7d7d7d;
}
.progressbar li:before {
width: 30px;
height: 30px;
content: counter(step);
counter-increment: step;
line-height: 30px;
border: 2px solid #7d7d7d;
display: block;
text-align: center;
margin: 0 auto 10px auto;
border-radius: 50%;
background-color: white;
}
.progressbar li:after {
width: 100%;
height: 2px;
content: '';
position: absolute;
background-color: #7d7d7d;
top: 15px;
left: -50%;
z-index: -1;
}
.progressbar li:first-child:after {
content: none;
}
.progressbar li.active {
color: green;
}
.progressbar li.active:before {
border-color: #55b776;
}
.progressbar li.active + li:after {
background-color: #55b776;
}
<h1>Four Steps</h1>
<div class="container">
<ul class="progressbar">
<li class="active">login</li>
<li>choose interest</li>
<li>add friends</li>
<li>View map</li>
</ul>
</div>
<h1> Seven Steps</h1>
<div class="container">
<ul class="progressbar">
<li class="active">login</li>
<li>choose interest</li>
<li>add friends</li>
<li>remove</li>
<li>fix users</li>
<li>review</li>
<li>save all</li>
</ul>
</div>

How to adjust the width of drop-down menu?

I am trying to adjust the width of the drop down menu, to match the width of the horizontal menu divider, under "Internship Program"
Any assistance would be greatly appreciated, thank you in advance.
Website is as following: http://amchaminternship.org/testimonials.html
a {
color: white;
}
.menu {
background: url(http://amchaminternship.org/images/menu-tail.gif) repeat-x 0% 0%;
margin: 0; padding: 0;
width: 100%;
height: 43px;
position: relative;
z-index: 1;
top: 175px;
right: 0;
}
.menu-item {
background: url(http://amchaminternship.org/images/menu-divider.gif) no-repeat 0% 50%;
display: block;
line-height: 40px;
float: left;
font-size: 1.083em;
padding: 0em 2em;
}
.menu-item:nth-of-type(1) {
background: none;
}
.menu-submenu {
margin: 0;
padding: 0;
position: absolute;
left: -9999em;
top: -9999em;
background-color: #123f69;
border-radius: 5px 5px 5px 5px;
border: 1px solid white;
}
.menu-item:hover > .menu-submenu {
left: auto;
top: auto;
}
.menu-submenu-item {
display: block;
}
.menu:after {
content: "";
display: table;
clear: both;
}
<ul class="menu">
<p style="margin-top: 0pt; margin-bottom: 0pt;"></p>
<li class="menu-item">Home</li>
<li class="menu-item">Internship Program
<ul class="menu-submenu">
<li class="menu-submenu-item">FAQ</li>
<li class="menu-submenu-item">Testimonials</li>
</ul>
</li>
<li class="menu-item">Alumni</li>
<li class="menu-item">Donations</li>
<li class="menu-item"><a href="who_we_are.html">Who
We Are</a></li>
<li class="menu-item"><a href="photo_gallery.html">Photo
Gallery</a></li>
<li class="menu-item"><a href="contact_us.html">Contact
Us</a></li>
</ul>
just try it.
.menu-submenu{
min-width: 140px;
max-width: 140px;
width: auto;
margin-left: -5px;
text-indent: 5px;
}
I hope it will full fill your requirement.
Try giving width to the submenu item e.g.
.menu-submenu {
width: 140px;
}
Add this two lines in your .menu-submenu class
width: 140px;
padding-left: 10px;
Please Refer the given code :
.menu-submenu {
margin: 0;
padding: 0;
position: absolute;
left: -9999em;
top: -9999em;
background-color: #123f69;
border-radius: 5px 5px 5px 5px;
border: 1px solid white;
width: 140px;
padding-left: 10px;
}
I hope it may help you to get the idea. Now you can adjust width according your requirements
Thanks.
what you have to change is as
.menu-submenu {
margin: 0;
margin-left:-2em;
padding: 0 3em;
width:inherit;
}
by negative margin we shift the box and by inheriting width we give same width as parent
a {
color: white;
}
.menu {
background: url(http://amchaminternship.org/images/menu-tail.gif) repeat-x 0% 0%;
margin: 0; padding: 0;
width: 100%;
height: 43px;
position: relative;
z-index: 1;
top: 175px;
right: 0;
}
.menu-item {
background: url(http://amchaminternship.org/images/menu-divider.gif) no-repeat 0% 50%;
display: block;
line-height: 40px;
float: left;
font-size: 1.083em;
padding: 0em 2em;
}
.menu-item:nth-of-type(1) {
background: none;
}
.menu-submenu {
margin: 0;
margin-left:-2em;
padding: 0 3em;
width:inherit;
position: absolute;
left: -9999em;
top: -9999em;
background-color: #123f69;
border-radius: 5px 5px 5px 5px;
border: 1px solid white;
}
.menu-item:hover > .menu-submenu {
left: auto;
top: auto;
}
.menu-submenu-item {
display: block;
}
.menu:after {
content: "";
display: table;
clear: both;
}
<ul class="menu">
<p style="margin-top: 0pt; margin-bottom: 0pt;"></p>
<li class="menu-item">Home</li>
<li class="menu-item">Internship Program
<ul class="menu-submenu">
<li class="menu-submenu-item">FAQ</li>
<li class="menu-submenu-item">Testimonials</li>
</ul>
</li>
<li class="menu-item">Alumni</li>
<li class="menu-item">Donations</li>
<li class="menu-item"><a href="who_we_are.html">Who
We Are</a></li>
<li class="menu-item"><a href="photo_gallery.html">Photo
Gallery</a></li>
<li class="menu-item"><a href="contact_us.html">Contact
Us</a></li>
</ul>
Add below code.
.menu-submenu{
width:120px !important;
padding-left:10px;
}