I'm trying to draw additional (mock) buttons onto my page with plain CSS, but my span element is not showing up. I've tried giving it a display: block; and I've also tried positioning it absolutely, but nothing seems to work. And out of those two ways, which is the preferred/most clear method?
header {
position: relative;
display: flex;
justify-content: space-around;
border-bottom: 6px solid black;
padding: 15px 0 10px 0;
}
img {
width: 43px;
height: 43px;
}
.red-button {
background: yellow;
width: 50px;
height: 50px;
}
header:before {
content: "";
position: absolute;
z-index: 1;
top: 74px;
width: 100%;
border-bottom: 6px solid maroon;
}
header:after {
content: "";
position: absolute;
top: 0;
width: 100%;
border-bottom: 6px solid $light-red;
}
<body>
<header>
<img src="./assets/pokeball.svg" alt="pokedex">
<span className="red-button"></span>
</header>
</body>
Just try to replace className by class.
This question already has answers here:
CSS technique for a horizontal line with words in the middle
(34 answers)
Closed 3 years ago.
I have the following HTML and CSS:
body {
text-align: center;
}
div {
border: 1px solid black;
margin: 0 auto;
width: 200px;
}
p {
border: 1px solid red;
line-height: 0.5;
margin: 20px;
text-align: center;
}
span {
display: inline-block;
position: relative;
}
span:before,
span:after {
content: "";
position: absolute;
height: 5px;
border-bottom: 1px solid black;
top: 0;
width: 100%;
}
span:before {
right: 100%;
margin-right: 20px;
}
span:after {
left: 100%;
margin-left: 20px;
}
<div>
<p class="strike"><span>Phrase</span></p>
</div>
I added a line on left and right of text but with 2 problems:
The line gets outside of the P border;
The P does not fill the entire width off the container DIV.
How can I solve these problems?
I've left your original CSS in but commented much of it out. FlexBox is a good way to achieve what you want (as opposed to position: absolute and position: relative:
/*body {
text-align: center;
}*/
div {
border: 1px solid black;
margin: 0 auto;
width: 200px;
}
p {
border: 1px solid red;
/*line-height: 0.5;*/
/*margin: 20px;*/
/*text-align: center;*/
}
span {
display: flex;
/*position: relative;*/
/*width: 100%;*/
align-items: center;
}
span:before,
span:after {
content: "";
/*position: absolute;*/
/*height: 5px;*/
border-bottom: 1px solid black;
/*top: 0;*/
width: 100%;
}
span:before {
/*right: 100%;*/
margin-right: 20px;
}
span:after {
/*left: 100%;*/
margin-left: 20px;
}
<div>
<p class="strike"><span>Phrase</span></p>
</div>
use left:0; and right:0 to make sure the lines stay within the borders
The margins you have on the p is what's stopping it from filling the entire width of the container.
Also the span is not really needed.
body {
text-align: center;
}
div {
border: 1px solid black;
margin: 0 auto;
width: 200px;
}
p {
border: 1px solid red;
line-height: 0.5;
/* margin: 20px; to span full width*/
text-align: center;
position: relative;
}
p:before,
p:after {
content: "";
position: absolute;
height: 1px;
background:black;
top: 50%;
transform:translateY(-50%);
width: 20%;
}
p:before {
left: 0;
}
p:after {
right: 0;
}
<div>
<p class="strike">Phrase</p>
</div>
I'd like some help to integrate a design made on sketch 2 years ago ! The goal is to do a beautiful orderer list but I have difficulties to integrate the content.
This is what i've done so far :
HTML :
<div class="stepbar_block">
<ol class="stepbar_list">
<li class="stepbar_list_elem_active"> 50% </li>
<li class="stepbar_list_item">60% </li>
<li class="stepbar_list_item">70%</li>
<li class="stepbar_list_elem_current">80%</li>
<li class="stepbar_list_item">90%</li>
</ol>
</div>
CSS :
.stepbar_block {
margin: 0;
padding: 0;
counter-reset: step;
position: relative;
margin-top: 40px;
}
.stepbar_block:before {
width: 1px;
height :10px;
background-color : rgba(87,87,86,0.3);
content : '';
position : absolute;
left : 30px;
top : -4px;
}
.stepbar_block:after {
width: 1px;
height :10px;
background-color : rgba(87,87,86,0.3);
content : '';
position : absolute;
right : 30px;
top : -4px;
}
.stepbar_list li {
list-style-type: none;
float: left;
width: 20%;
height : 5px;
position: relative;
font-family: Roboto;
font-size: 10px;
line-height: 11px;
text-align: center;
color: rgba(87,87,86,0.5);
}
.stepbar_list:after {
content: '';
position: absolute;
height: 1px;
background-color: rgba(87,87,86,0.3);
left: 30px;
right: 30px;
z-index: 3;
}
.stepbar_list li:before {
content : '';
counter-increment: step;
width: 5px;
height: 5px;
border: 1px solid black;
display: block;
background-color : black;
border-radius: 40px;
text-align: center;
margin: -2px auto 10px auto;
}
.stepbar_list_item:after {
content: counter(step);
position: absolute;
top: -25px;
background-color: white;
left: 0;
right: 0;
color: rgba(87,87,86,0.5);
font-size: 10px;
line-height: 11px; text-align: center;
}
.stepbar_list_elem_active:after {
content: counter(step);
position: absolute;
top: -25px;
background-color: red;
left: 0;
right: 0;
}
.stepbar_list_elem_current:after {
content: counter(step);
position: absolute;
top: -25px;
background-color: blue;
left: 0;
right: 0;
}
https://jsfiddle.net/zawt9hL6/
However I'm able to colorise the items but not the circles, so I'd like to know what is missing because when I play with :before and :after it seems to colorize the whole list item and not a specific content
That is the result i'd like to have
It is possible to have a render like this ? Moreover it's a gradiant background on the circles..
THank you for advices
Use something like this for all.
.stepbar_list_elem_active:before {
width: 10px;
height: 10px;
background-color: #fff;
content: '';
position: absolute;
left: 0;
top: -6px;
border: 2px solid red;
border-radius: 50%;
right: 0;
margin: 0 auto;
}
You can use :before and :after pseudo elements to create that circle with gradient. First you can create just regular circle with gradient and then add one more white circle with other pseudo-element on top of the frist one.
10* {
box-sizing: border-box;
}
ul {
display: inline-flex;
list-style: none;
position: relative;
padding: 0;
margin: 0 50px;
}
ul:after {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 2px;
background: gray;
}
li {
padding: 25px;
position: relative;
}
li:after,
li.color:before {
position: absolute;
content: '';
bottom: 0;
left: 50%;
height: 10px;
width: 10px;
background: gray;
border-radius: 50%;
transform: translate(-50%, 40%);
z-index: 1;
}
li.color:after {
width: 20px;
height: 20px;
transform: translate(-50%, 9px);
}
li.color:before {
background: white;
z-index: 2;
width: 10px;
height: 10px;
}
li.yellow:after {
background: linear-gradient(to right, rgba(240,184,88,1) 0%, rgba(230,139,60,1) 38%, rgba(240,47,23,1) 71%, rgba(231,56,39,1) 100%);
}
li.blue:after {
background: linear-gradient(to right, rgba(52,163,247,1) 0%, rgba(52,163,247,1) 32%, rgba(19,100,158,1) 71%, rgba(19,100,158,1) 100%);
}
.yellow {
color: #ED4620;
}
.blue {
color: #64A3D1;
}
<ul>
<li>1</li>
<li class="color yellow">2</li>
<li class="color blue">3</li>
<li>4</li>
</ul>
I need when you hover a mouse on one div other div with parametres appear from below and these both divs have common border.
Now I have border only on first div. It looks like first div don't contain second, but in html code div with parametres is beetwen of first.
What is wrong?
.item {
width: 220px;
height: 300px;
margin: 10px 3px;
float: left;
position: relative;
}
.item:hover .item_inner {
position: absolute;
top: 0;
left: 0;
z-index: 10;
background: #fff;
box-shadow: 0 1px 14px rgba(0,0,0,0.3);
height: 100%;
}
.item_param {
display: none;
text-align: left;
padding: 0 5px;
margin: 10px 0;
background-color: #f3f3f3;
}
.item_inner{
width: 100%;
height: 100%;
position: relative;
padding-bottom: 5px;
border: 1px solid green;
}
.item_inner:hover .item_param {
display: block;
top: 100%;
width: 100%;
position: absolute;
}
<div class="item">
<div class="item_inner">
TEXT
<div class="item_param">
<p>Parametres</p>
<p>Parametres</p>
<p>Parametres</p>
</div>
</div>
</div>
.item_inner:hover .item_param {
display: block;
top: 100%;
width: 100%;
position: relative;
}
I am trying to achieve the following, with pure CSS and no images:
As you can see, its a heading with a line afterwards. The problem is, that the line should has 2 different colors and more important, 2 different heights.
The first parts color is orange, has a height of 3px and a fixed width of 100px (padding-left: 15px)
The sedond parts color is #E1E1E1 and should fill the rest of the line.
My first try was this:
<h1><span>OUR ARTICLES</span></h1>
<style>
h1 {
overflow: hidden;
}
h1 span {
display: inline-block;
position: relative;
}
h1 span:after {
content: "";
position: absolute;
height: 1px;
top: 45%;
width: 999px;
background: #E1E1E1;
border-left: 100px solid orange;
left: 100%;
margin-left: 15px;
}
</style>
See http://jsfiddle.net/oyxmxoLs/
But as you can see, I can't make the orange part thicker than the grey one.
Any ideas?
Another way: Flexbox
With display: flex you don't have to give the line a certain width and you can make sure it is always responsive.
We are going here with an progressive enhancement approach. We'll make a cut after IE8 by using ::before instead of :before. In IE9 only the grey line will be shown (underneath the title).
h1 {
align-items: center;
color: #444;
display: flex;
font: 18px/1.3 sans-serif;
margin: 18px 15px;
white-space: nowrap;
}
h1::before {
background-color: orange;
content: "";
height: 4px;
margin-left: 10px;
order: 2;
width: 100px;
}
h1::after {
background-color: #E1E1E1;
content: "";
display: block;
height: 2px;
order: 3;
width: 100%;
}
<h1>Our articles</h1>
Do not forget to add vendor-prefixes!
You can solve this by using :before and :after
http://jsfiddle.net/oyxmxoLs/1/
h1 {
overflow: hidden;
}
h1 span {
display: inline-block;
position: relative;
}
h1 span:before {
content: "";
position: absolute;
height: 1px;
top: 45%;
width: 999px;
background: #E1E1E1;
left: 100%;
margin-left: 15px;
}
h1 span:after {
content: "";
position: absolute;
height: 3px;
top: 45%;
width: 100px;
background: orange;
left: 100%;
margin-left: 15px;
margin-top:-1px;
}
<h1><span>OUR ARTICLES</span></h1>
You can also use the :before pseudo-element to add the orange line.
h1 {
overflow: hidden;
}
h1 span {
display: inline-block;
position: relative;
}
h1 span:after, h1 span:before {
content: "";
position: absolute;
height: 1px;
left: 100%;
top: 45%;
margin-left: 15px;
}
h1 span:after {
width: 999px;
background: #E1E1E1;
}
h1 span:before {
height: 3px;
z-index: 1;
margin-top: -1px;
border-radius: 2px;
width: 100px;
background: orange;
}
<h1><span>OUR ARTICLES</span></h1>