Related
I've never asked a css question before so apologies in advance.
This is what my nav bar looks like currently
full sized image here
Two things I really want to achieve:
round of the tabs just above and below the current tab
(in this picture it would be Suggestions and About Us)
shadow the nav bar on the right side except the current tab
(I'm using jinja2 btw. Cannot hard code the corners since the current tab is not fixed)
I have no idea about 1. but I tried 2. and this is the unsatisfied result:
would like to get rid of the abrupt corners
This is my current stylesheet
:root {
/* colour palette */
--cream : hsl(40, 100%, 96%);
--cream-light:hsl(40, 100%, 98%);
--coffee: hsl(40, 14%, 62%);
--purple: hsl(258, 14%, 62%);
--dark : hsl(109, 7%, 33%);
--green : hsl(128, 30%, 42%);
--green2: hsl(140, 15%, 55%);
--green2-dark: hsl(140, 11%, 36%);
/* */
--shadow-in: inset 1px .15rem .3rem -.1rem rgba(50, 50, 93, 0.25), inset 1px .1rem .2rem -.1rem rgba(0, 0, 0, 0.3), inset -1px -1px .3rem -.1rem rgba(50, 50, 93, 0.25), inset -1px -1px .2rem -.1rem rgba(0, 0, 0, 0.3);
--shadow-nav: .3rem 0 .6rem -.2rem rgba(50, 50, 93, 0.25), .2rem 0 .4rem -.2rem rgba(0, 0, 0, 0.3);
--shadow-current: inset .3rem .3rem .6rem -.2rem rgba(50, 50, 93, 0.25), inset .2rem .2rem .4rem -.2rem rgba(0, 0, 0, 0.3);
--shadow-hover: inset 1px .3rem .6rem -.2rem rgba(50, 50, 93, 0.25), inset 1px .2rem .4rem -.2rem rgba(0, 0, 0, 0.3), inset -1px -1px .6rem -.2rem rgba(50, 50, 93, 0.25), inset -1px -1px .4rem -.2rem rgba(0, 0, 0, 0.3);
/* themes */
--nav-bg : var(--green2-dark);
--nav-text : white;
--nav-hover: hsl(140, 11%, 27%);
--main : var(--cream );
--text : var(--dark );
--highlight: var(--green);
--card : var(--cream-light);
}
html, body {
margin: 0;
font-size: 1.5vw;
background: var(--nav-bg);
transition: all .5s ease;
}
a {
color: var(--text);
text-decoration: none;
}
a:hover {
color: var(--green);
}
nav {
position: fixed;
top: 0;
left: 0;
width: 18%;
height: 100vh;
/*box-shadow: var(--shadow-nav);*/
/*box-shadow: .3rem 0 .6rem rgba(50, 93, 50, 0.25), .2rem 0 .4rem rgba(0, 0, 0, 0.3);*/
background: var(--nav-bg);
}
nav h2 {
margin: 0;
padding: 10%;
padding-right: 0 !important;
height: 1.8rem;
background: var(--nav-bg);
color: var(--nav-text);
transition: margin .5s, padding .5s, border .5s, background .5s, color .3s;
}
/*nav div.current {
width: 100%;
padding-right: .9rem;
background: linear-gradient(90deg, hsl(140, 11%, 36%) 50%, hsl(40, 100%, 96%) 50%);
}
nav div.current:hover {
padding-right: 0;
}*/
nav h2.current {
margin-left: 5%;
padding-left: 5%;
border-radius: .5rem 0 0 .5rem;
box-shadow: var(--shadow-current);
background: var(--main);
color: var(--text);
}
nav h2:hover {
margin: 0;
padding: 10%;
padding-left: 15%;
border-radius: 0;
box-shadow: var(--shadow-hover);
background: var(--nav-hover);
color: var(--nav-text);
}
main {
padding-left: 22.5%;
padding-right: 7.5%;
min-height: 100vh;
background: var(--main);
color: var(--text);
display: flex;
flex-direction: column;
}
main h1 {
color: var(--green2);
}
footer {
margin-top: auto;
margin-bottom: .35rem;
padding: .25rem;
padding-right: 2.5rem;
border-radius: .25rem;
font: .5rem sans-serif;
text-align: right;
background: hsl(40, 39%, 90%);
box-shadow: var(--shadow-in);
}
and this is layout.html
<!DOCTYPE html>
<html lang='en'>
<head>
<title>Library</title>
<meta charset='UTF-8'>
</head>
<body>
<nav>
{% include 'navigation.html' %}
</nav>
<main>
{% block main %} {% endblock %}
<footer>Copyright 2021 mightbesimon | github.com/mightbesimon</footer>
</main>
</body>
</html>
and this is navigation.html
{% for url, name in (('/' , 'Home' ),
('/register' , 'Register' ),
('/login' , 'Login' ),
('/suggestions', 'Suggestions' ),
('/catalogue' , 'Our Catalogue'),
('/aboutus' , 'About Us' ),
('/contact' , 'Contact' ),
) %}
<a href="{{ url }}">
<!-- <div {% if url_for(request.endpoint, **request.view_args)==url %} class="current" {% endif %}> -->
<h2 {% if url_for(request.endpoint, **request.view_args)==url %} class="current" {% endif %}>
{{ name }}
</h2>
<!-- </div> -->
</a>
{% endfor %}
You could give a try to
drop-shadow() (but it will do on any translucide edges => text too unfortunately) to draw the shadow via filter .
box-shadow from .current to paint the nav background
overflow:hidden on nav to avoid shadow to bleed on main
position: relative for h2 to remain on top of the shadow & static for .current
here is the idea of possible update
:root {
/* colour palette */
--cream: hsl(40, 100%, 96%);
--cream-light: hsl(40, 100%, 98%);
--coffee: hsl(40, 14%, 62%);
--purple: hsl(258, 14%, 62%);
--dark: hsl(109, 7%, 33%);
--green: hsl(128, 30%, 42%);
--green2: hsl(140, 15%, 55%);
--green2-dark: hsl(140, 11%, 36%);
/* */
--shadow-in: inset 1px 0.15rem 0.3rem -0.1rem rgba(50, 50, 93, 0.25),
inset 1px 0.1rem 0.2rem -0.1rem rgba(0, 0, 0, 0.3),
inset -1px -1px 0.3rem -0.1rem rgba(50, 50, 93, 0.25),
inset -1px -1px 0.2rem -0.1rem rgba(0, 0, 0, 0.3);
--shadow-nav: 0.3rem 0 0.6rem -0.2rem rgba(50, 50, 93, 0.25),
0.2rem 0 0.4rem -0.2rem rgba(0, 0, 0, 0.3);
--shadow-current: inset 0.3rem 0.3rem 0.6rem -0.2rem rgba(50, 50, 93, 0.25),
inset 0.2rem 0.2rem 0.4rem -0.2rem rgba(0, 0, 0, 0.3);
--shadow-hover: inset 1px 0.3rem 0.6rem -0.2rem rgba(50, 50, 93, 0.25),
inset 1px 0.2rem 0.4rem -0.2rem rgba(0, 0, 0, 0.3),
inset -1px -1px 0.6rem -0.2rem rgba(50, 50, 93, 0.25),
inset -1px -1px 0.4rem -0.2rem rgba(0, 0, 0, 0.3);
/* themes */
--nav-bg: var(--green2-dark);
--nav-text: white;
--nav-hover: hsl(140, 11%, 27%);
--main: var(--cream);
--text: var(--dark);
--highlight: var(--green);
--card: var(--cream-light);
}
html,
body {
margin: 0;
font-size: 1.5vw;
background: var(--nav-bg);
transition: all 0.5s ease;
}
a {
color: var(--text);
text-decoration: none;
}
a:hover {
color: var(--green);
}
nav {
position: fixed;
top: -1rem;
bottom: -1rem;
left: 0;
width: 18%;
padding: 1rem 0;
min-height:100vh;
overflow: hidden;
filter: drop-shadow(0.3rem 0.3rem 0.6rem);
}
nav h2 {
margin: 0;
padding: 10%;
padding-right: 0 !important;
height: 1.8rem;
transition: margin 0.5s, padding 0.5s, border 0.5s, background 0.5s,
color 0.3s;
position: relative;
color: var(--nav-text);
}
nav h2.current:hover {
box-shadow: var(--shadow-hover), 0 0 0 100vw var(--nav-bg);
}
nav h2.current {
margin-left: 5%;
padding-left: 5%;
border-radius: 0.5rem 0 0 0.5rem;
box-shadow: 0 0 0 100vmax var(--nav-bg);
color: var(--text);
position: static;
}
nav h2:hover {
margin: 0;
padding: 10%;
padding-left: 15%;
border-radius: 0;
box-shadow: var(--shadow-hover);
background: var(--nav-hover);
color: var(--nav-text);
}
main {
padding-left: 22.5%;
padding-right: 7.5%;
min-height: 100vh;
background: var(--main);
color: var(--text);
display: flex;
flex-direction: column;
}
main h1 {
color: var(--green2);
}
footer {
margin-top: auto;
margin-bottom: 0.35rem;
padding: 0.25rem;
padding-right: 2.5rem;
border-radius: 0.25rem;
font: 0.5rem sans-serif;
text-align: right;
background: hsl(40, 39%, 90%);
box-shadow: var(--shadow-in);
}
https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function/drop-shadow()
Note: This function is somewhat similar to the box-shadow property. The box-shadow property creates a rectangular shadow behind an element's entire box, while the drop-shadow() filter function creates a shadow that conforms to the shape (alpha channel) of the image itself.
Is there a way to create a dashed border with two alternating colours in CSS?
.twoColourBorder {
border: 2px dashed red, blue;
}
Edit 1
Perhaps stacked dashed borders (white, red, white, blue)?
Edit 2
Ideally not; however, should I consider a border img?
Edit 3
Leaning toward a gradient solution. Still struggling though.
Edit 4
Dylan pointed out below that perhaps stroke-dasharray could work. On it.
Built on Yadab's answer, adding a pseudo element to fix the vertical border.
Basically you create a line with repeating-linear-gradient and set it to border-image.
:root {
--border-size: 2px;
--box-width: 36em;
--box-height: 8em;
--dash-size: 1em;
}
.box,
.box::after {
height: var(--box-height);
width: var(--box-width);
border: solid;
}
.box {
border-image: repeating-linear-gradient( to right, red 0, red var(--dash-size), transparent var(--dash-size), transparent calc(var(--dash-size) * 2), blue calc(var(--dash-size) * 2), blue calc(var(--dash-size) * 3), transparent calc(var(--dash-size) * 3), transparent calc(var(--dash-size) * 4));
border-image-slice: 16;
border-image-width: var(--border-size) 0;
}
.box::after {
content: "";
top: 0;
position: absolute;
border-image: repeating-linear-gradient( to bottom, blue 0, blue var(--dash-size), transparent var(--dash-size), transparent calc(var(--dash-size) * 2), red calc(var(--dash-size) * 2), red calc(var(--dash-size) * 3), transparent calc(var(--dash-size) * 3), transparent calc(var(--dash-size) * 4));
border-image-slice: 16;
border-image-width: 0 var(--border-size);
}
<div class="box"></div>
.boxborder-me {
box-shadow: 0 0 0 5px red;
outline: dashed 5px blue;
height: 100px;
}
<div class="boxborder-me"></div>
This should help you.
.box {
padding: 1rem;
border: 5px solid transparent;
border-image: 16 repeating-linear-gradient(-45deg, red 0, red 1em, transparent 0, transparent 2em,
#58a 0, #58a 3em, transparent 0, transparent 4em);
max-width: 20em;
font: 100%/1.6 Baskerville, Palatino, serif;
}
<div class="box" />
I know it isn't perfect and a better answer most definitely exists! (I am strapped for time to answer this) Treat this more a proof of concept that you can get the look your after by using the following:
#multiColor {
height: 100px;
width: 340px;
border: solid 5px;
border-image: url('../../../assets/images/border.png') 10 / 10px round;
}
Here is the image I edited in photoshop:
EDIT
After more research I started researching svg stroke-dasharray and have come up with something that might help us get to a final solution:
https://jsfiddle.net/wtcmpx98/52/
<svg viewbox="0 0 200 150" xmlns="http://www.w3.org/2000/svg" version="1.1">
<rect class="red"/>
<rect class="blue"/>
<rect class="white"/>
<!--<rect class="white-2"/>-->
</svg>
svg {
top: 10px;
left: 10px;
fill: none;
width: 500px;
height: 500px;
}
.red,
.blue,
.white {
x: 10px;
y: 10px;
height: 150px;
width: 150px;
}
.red {
stroke: red;
stroke-width: 5;
stroke-dasharray: 0,0,0;
}
.white {
stroke: white;
stroke-width: 6px;
stroke-dasharray: 5,5,5;
}
.blue {
stroke: blue;
stroke-width: 5;
stroke-dasharray: 10,10,10;
}
.white-2 {
stroke: white;
stroke-width: 6px;
stroke-dasharray: 15,15,15;
}
The following demo uses background: linear-gradient() on a total of 16 <div> positioned absolute within a relatively positioned <div>. It's a little rough -- the corners are not perfect when resized.
Demo
Drag the bottom right corner of rectangle to resize
* {
padding: 0;
margin: 0;
}
.box {
position: relative;
width: 30vw;
height: 50vh;
padding: 4px;
margin: 25vh auto;
resize: both;
overflow: auto;
}
.box div {
position: absolute;
}
.n {
width: 25%;
height: 4px;
background: linear-gradient(to right, rgba(255, 0, 0, 1) 0%, rgba(255, 0, 0, 1)33%, rgba(255, 255, 255, 1) 33%, rgba(255, 255, 255, 1) 66%, rgba(0, 0, 255, 1) 66%, rgba(0, 0, 255, 1) 100%) repeat 10% 100%;
top: 0;
}
.e {
width: 4px;
height: 25%;
background: linear-gradient(to bottom, rgba(255, 0, 0, 1) 0%, rgba(255, 0, 0, 1)33%, rgba(255, 255, 255, 1) 33%, rgba(255, 255, 255, 1) 66%, rgba(0, 0, 255, 1) 66%, rgba(0, 0, 255, 1) 100%) repeat 100% 10%;
right: 0;
}
.s {
width: 25%;
height: 4px;
background: linear-gradient(to left, rgba(255, 0, 0, 1) 0%, rgba(255, 0, 0, 1)33%, rgba(255, 255, 255, 1) 33%, rgba(255, 255, 255, 1) 66%, rgba(0, 0, 255, 1) 66%, rgba(0, 0, 255, 1) 100%) repeat 10% 100%;
bottom: 0;
}
.w {
width: 4px;
height: 25%;
background: linear-gradient(to top, rgba(255, 0, 0, 1) 0%, rgba(255, 0, 0, 1)33%, rgba(255, 255, 255, 1) 33%, rgba(255, 255, 255, 1) 66%, rgba(0, 0, 255, 1) 66%, rgba(0, 0, 255, 1) 100%);
left: 0;
}
.r1 {
right: 0
}
.r2 {
right: 25%
}
.r3 {
right: 50%
}
.r4 {
right: 75%
}
.b1 {
bottom: 0
}
.b2 {
bottom: 25%
}
.b3 {
bottom: 50%
}
.b4 {
bottom: 75%
}
.l1 {
left: 0
}
.l2 {
left: 25%
}
.l3 {
left: 50%
}
.l4 {
left: 75%
}
.t1 {
top: 0
}
.t2 {
top: 25%
}
.t3 {
top: 50%
}
.t4 {
top: 75%
}
<div class='box'>
<div class='n r1'></div>
<div class='n r2'></div>
<div class='n r3'></div>
<div class='n r4'></div>
<div class='e b1'></div>
<div class='e b2'></div>
<div class='e b3'></div>
<div class='e b4'></div>
<div class='s l1'></div>
<div class='s l2'></div>
<div class='s l3'></div>
<div class='s l4'></div>
<div class='w t1'></div>
<div class='w t2'></div>
<div class='w t3'></div>
<div class='w t4'></div>
</div>
Im looking for some help on a project I am working on. im having some issues on Iphone. On all other devices the hotspots work.
you can see on the iphone version of Browser stack that the shadow is a square where as it should be rounded like on all other devices. the problem is at.
https://www.schock.de/
homepage hotspots on mobile. in the Inspector everything seems to be working, its only if you view it on a Iphone!!!!
IPhone hotspots
version working on all devices
<div #if.isNotBackendContext={!node.context.inBackend} class="product__hotspot" style={props.styleCoordinates}>
<a href={props.link} class="product__hotspot--link">
<span class="product-hotspot">
<svg class="hotspot-img" width="50" height="50" viewBox="0 0 41 42" fill="none"
xmlns="http://www.w3.org/2000/svg">
<ellipse cx="20.5833" cy="21.2286" rx="10.8088" ry="10.8" fill="white"/>
<path
d="M39 21.2286C39 31.3891 30.7561 39.6286 20.5833 39.6286C10.4106 39.6286 2.16667 31.3891 2.16667 21.2286C2.16667 11.0681 10.4106 2.82855 20.5833 2.82855C30.7561 2.82855 39 11.0681 39 21.2286Z"
stroke="white" stroke-width="3"/>
</svg>
</span>
<span class="product__hotspot--title">
{props.titleText}
</span>
</a>
</div>
<div #if.isNotBackendContext={node.context.inBackend} class="product__hotspot backend"
style={props.styleCoordinates}>
<div #if.isNotBackendContext={node.context.inBackend} class="product__hotspot--link">
{props.title}
</div>
<div class={props.saveButtonClass}>Save position</div>
</div>
.image-with-hotspots {
position: relative;
.hotspot-container {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.product__hotspot {
position: absolute;
&.backend {
text-align: left;
.product__hotspot--link {
background-color: $color-primary;
padding: 10px;
color: $white;
font-size: 12px;
&:hover {
width: 50px;
}
}
.save-btn {
background-color: $color-green-light;
color: $white;
padding: 10px;
font-size: 12px;
cursor: pointer;
&:hover {
background-color: $color-green-dark;
}
}
}
.product__hotspot--link {
width: 50px;
height: 50px;
display: inline-block;
border-radius: 40px;
outline: 0;
transition: all 0.3s linear;
#include media-breakpoint-down(sm) {
width: 30px;
height: 30px;
}
&:hover {
width: auto;
background-color: $color-primary;
.product__hotspot--title {
opacity: 1;
}
}
.product-hotspot {
position: relative;
width: auto;
display: inline-block;
.hotspot-img {
animation: pulse 2s infinite;
box-shadow: 10px 10px 10px rgba(255, 255, 255, 1);
-webkit-appearance: none;
border-radius: 100% !important;
&:hover {
animation: none;
box-shadow: none;
}
#include media-breakpoint-down(sm) {
width: 30px;
height: 30px;
}
}
}
.product__hotspot--title {
opacity: 0;
font-family: $font-family-gotham-bold;
font-size: 13px;
color: $white;
padding: 0 20px;
text-transform: uppercase;
#include media-breakpoint-down(sm) {
font-size: 10px;
padding: 0 8px;
}
}
}
}
}
#keyframes pulse {
0% {
-moz-box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.8);
box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.8);
transform: scale(1.1);
}
70% {
-moz-box-shadow: 0 0 0 10px rgba(255, 255, 255, 0);
box-shadow: 0 0 0 10px rgba(255, 255, 255, 0);
transform: scale(1)
}
100% {
-moz-box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
transform: scale(1);
}
}
#include media-breakpoint-down(sm) {
#keyframes pulse {
0% {
-moz-box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.8);
box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.8);
transform: scale(1.1);
}
70% {
-moz-box-shadow: 0 0 0 5px rgba(255, 255, 255, 0);
box-shadow: 0 0 0 5px rgba(255, 255, 255, 0);
transform: scale(1)
}
100% {
-moz-box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
transform: scale(1);
}
}
}
I have tried updating border-radius to make square from circle but size is very small. I want to increase size of each square. Width & Height changes aren't making any difference.
If someone can help in making it usable or provide similar code with big boxes.
Let me know if any further details needed.
#-webkit-keyframes myanimation {
from {
left: 0%;
}
to {
left: 100%;
}
}
h1 {
text-align: center;
font-family: 'PT Sans Caption', sans-serif;
font-weight: 400;
font-size: 20px;
padding: 20px 0;
color: #777;
}
.checkout-wrap {
color: #444;
font-family: 'PT Sans Caption', sans-serif;
margin: 40px auto;
max-width: 1200px;
position: relative;
}
ul.checkout-bar li {
color: #ccc;
display: block;
font-size: 16px;
font-weight: 600;
padding: 14px 20px 14px 80px;
position: relative;
}
ul.checkout-bar li:before {
-webkit-box-shadow: inset 2px 2px 2px 0px rgba(0, 0, 0, 0.2);
box-shadow: inset 2px 2px 2px 0px rgba(0, 0, 0, 0.2);
background: #ddd;
border: 2px solid #FFF;
border-radius: 20%;
color: #fff;
font-size: 16px;
font-weight: 700;
left: 20px;
line-height: 37px;
height: 35px;
position: absolute;
text-align: center;
text-shadow: 1px 1px rgba(0, 0, 0, 0.2);
top: 4px;
width: 35px;
z-index: 999;
}
ul.checkout-bar li.active {
color: #8bc53f;
font-weight: bold;
}
ul.checkout-bar li.active:before {
background: #8bc53f;
z-index: 99999;
}
ul.checkout-bar li.visited {
background: #ECECEC;
color: #57aed1;
z-index: 99999;
}
ul.checkout-bar li.visited:before {
background: #57aed1;
z-index: 99999;
}
ul.checkout-bar li:nth-child(1):before {
content: "1";
}
ul.checkout-bar li:nth-child(2):before {
content: "2";
}
ul.checkout-bar li:nth-child(3):before {
content: "3";
}
ul.checkout-bar li:nth-child(4):before {
content: "4";
}
ul.checkout-bar li:nth-child(5):before {
content: "5";
}
ul.checkout-bar li:nth-child(6):before {
content: "6";
}
ul.checkout-bar a {
color: #57aed1;
font-size: 16px;
font-weight: 600;
text-decoration: none;
}
#media all and (min-width: 800px) {
.checkout-bar li.active:after {
-webkit-animation: myanimation 3s 0;
background-size: 35px 35px;
background-color: #8bc53f;
background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent);
background-image: -moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent);
-webkit-box-shadow: inset 2px 2px 2px 0px rgba(0, 0, 0, 0.2);
box-shadow: inset 2px 2px 2px 0px rgba(0, 0, 0, 0.2);
content: "";
height: 15px;
width: 100%;
left: 50%;
position: absolute;
top: -50px;
z-index: 0;
}
.checkout-wrap {
margin: 80px auto;
}
ul.checkout-bar {
-webkit-box-shadow: inset 2px 2px 2px 0px rgba(0, 0, 0, 0.2);
box-shadow: inset 2px 2px 2px 0px rgba(0, 0, 0, 0.2);
background-size: 35px 35px;
background-color: #EcEcEc;
background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.4) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.4) 50%, rgba(255, 255, 255, 0.4) 75%, transparent 75%, transparent);
background-image: -moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.4) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.4) 50%, rgba(255, 255, 255, 0.4) 75%, transparent 75%, transparent);
border-radius: 15px;
height: 15px;
margin: 0 auto;
padding: 0;
position: absolute;
width: 100%;
}
ul.checkout-bar:before {
background-size: 35px 35px;
background-color: #57aed1;
background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent);
background-image: -moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent);
-webkit-box-shadow: inset 2px 2px 2px 0px rgba(0, 0, 0, 0.2);
box-shadow: inset 2px 2px 2px 0px rgba(0, 0, 0, 0.2);
border-radius: 15px;
content: " ";
height: 15px;
left: 0;
position: absolute;
width: 10%;
}
ul.checkout-bar li {
display: inline-block;
margin: 50px 0 0;
padding: 0;
text-align: center;
width: 19%;
}
ul.checkout-bar li:before {
height: 45px;
left: 40%;
line-height: 45px;
position: absolute;
top: -65px;
width: 45px;
z-index: 99;
}
ul.checkout-bar li.visited {
background: none;
}
ul.checkout-bar li.visited:after {
background-size: 35px 35px;
background-color: #57aed1;
background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent);
background-image: -moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent);
-webkit-box-shadow: inset 2px 2px 2px 0px rgba(0, 0, 0, 0.2);
box-shadow: inset 2px 2px 2px 0px rgba(0, 0, 0, 0.2);
content: "";
height: 15px;
left: 50%;
position: absolute;
top: -50px;
width: 100%;
z-index: 99;
}
}
<head>
<meta charset="UTF-8"/>
<title>Responsive Checkout Progress Bar</title>
</head>
<body>
<link href='http://fonts.googleapis.com/css?family=PT+Sans+Caption:400,700' rel='stylesheet' type='text/css'/>
<h1>Responsive Checkout Progress Bar</h1>
<div class="checkout-wrap">
<ul class="checkout-bar">
<li class="visited first">Possible candidate</li>
<li class="previous visited">Forwarded to manager</li>
<li class="active">Phone screen</li>
<li class="next">Interview</li>
<li class="">Complete</li>
<li class="">Cancelled</li>
</ul>
</div>
</body>
Let's take a look at the rules, you will find the following rule:
ul.checkout-bar li:before {
-webkit-box-shadow: inset 2px 2px 2px 0px rgba(0, 0, 0, 0.2);
box-shadow: inset 2px 2px 2px 0px rgba(0, 0, 0, 0.2);
background: #ddd;
border: 2px solid #FFF;
border-radius: 20%;
color: #fff;
font-size: 16px;
font-weight: 700;
left: 20px;
line-height: 37px;
height: 35px;
position: absolute;
text-align: center;
text-shadow: 1px 1px rgba(0, 0, 0, 0.2);
top: 4px;
width: 35px;
z-index: 999;
}
If you change width and height of the previous rule nothing will happen if
it is displayed on a browser because you have another rule for the same selector inside a media query that is to be applied on screens with a width greater than 800px :
#media all and (min-width: 800px) {
...
ul.checkout-bar li:before {
height: 45px;
left: 40%;
line-height: 45px;
position: absolute;
top: -65px;
width: 45px;
z-index: 99;
}
...
}
The last rule is overriding the first rule because is inside a media query and you are probably displaying the file in a browser that is more than 800px. If you change the height and width of the second rule you'll see the changes. If the file is displayed in a the device with width lower than 800px then you the rule that will have effect is the first one.
I suggest you learn about media queries and to learn about using Developer Tools to debug code.
On small screen you need to adjust your #media all and (min-width: 800px) { ... ul.checkout-bar li:before ... } class's properties and on large screen you need to adjust ul.checkout-bar li:before,
properties that you need to adjust are: height, width, line-height, top
#-webkit-keyframes myanimation {
from {
left: 0%;
}
to {
left: 100%;
}
}
h1 {
text-align: center;
font-family: 'PT Sans Caption', sans-serif;
font-weight: 400;
font-size: 20px;
padding: 20px 0;
color: #777;
}
.checkout-wrap {
color: #444;
font-family: 'PT Sans Caption', sans-serif;
margin: 40px auto;
max-width: 1200px;
position: relative;
}
ul.checkout-bar li {
color: #ccc;
display: block;
font-size: 16px;
font-weight: 600;
padding: 14px 20px 14px 80px;
position: relative;
margin-top: 26px;
}
ul.checkout-bar li:before {
-webkit-box-shadow: inset 2px 2px 2px 0px rgba(0, 0, 0, 0.2);
box-shadow: inset 2px 2px 2px 0px rgba(0, 0, 0, 0.2);
background: #ddd;
border: 2px solid #FFF;
border-radius: 20%;
color: #fff;
font-size: 16px;
font-weight: 700;
left: 0px;
line-height: 70px;
height: 70px;
position: absolute;
text-align: center;
text-shadow: 1px 1px rgba(0, 0, 0, 0.2);
top: -80px;
width: 70px;
z-index: 999;
}
ul.checkout-bar li.active {
color: #8bc53f;
font-weight: bold;
}
ul.checkout-bar li.active:before {
background: #8bc53f;
z-index: 99999;
}
ul.checkout-bar li.visited {
background: #ECECEC;
color: #57aed1;
z-index: 99999;
}
ul.checkout-bar li.visited:before {
background: #57aed1;
z-index: 99999;
}
ul.checkout-bar li:nth-child(1):before {
content: "1";
}
ul.checkout-bar li:nth-child(2):before {
content: "2";
}
ul.checkout-bar li:nth-child(3):before {
content: "3";
}
ul.checkout-bar li:nth-child(4):before {
content: "4";
}
ul.checkout-bar li:nth-child(5):before {
content: "5";
}
ul.checkout-bar li:nth-child(6):before {
content: "6";
}
ul.checkout-bar a {
color: #57aed1;
font-size: 16px;
font-weight: 600;
text-decoration: none;
}
#media all and (min-width: 800px) {
.checkout-bar li.active:after {
-webkit-animation: myanimation 3s 0;
background-size: 35px 35px;
background-color: #8bc53f;
background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent);
background-image: -moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent);
-webkit-box-shadow: inset 2px 2px 2px 0px rgba(0, 0, 0, 0.2);
box-shadow: inset 2px 2px 2px 0px rgba(0, 0, 0, 0.2);
content: "";
height: 15px;
width: 100%;
left: 50%;
position: absolute;
top: -50px;
z-index: 0;
}
.checkout-wrap {
margin: 80px auto;
}
ul.checkout-bar {
-webkit-box-shadow: inset 2px 2px 2px 0px rgba(0, 0, 0, 0.2);
box-shadow: inset 2px 2px 2px 0px rgba(0, 0, 0, 0.2);
background-size: 35px 35px;
background-color: #EcEcEc;
background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.4) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.4) 50%, rgba(255, 255, 255, 0.4) 75%, transparent 75%, transparent);
background-image: -moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.4) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.4) 50%, rgba(255, 255, 255, 0.4) 75%, transparent 75%, transparent);
border-radius: 15px;
height: 15px;
margin: 0 auto;
padding: 0;
position: absolute;
width: 100%;
}
ul.checkout-bar:before {
background-size: 35px 35px;
background-color: #57aed1;
background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent);
background-image: -moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent);
-webkit-box-shadow: inset 2px 2px 2px 0px rgba(0, 0, 0, 0.2);
box-shadow: inset 2px 2px 2px 0px rgba(0, 0, 0, 0.2);
border-radius: 15px;
content: " ";
height: 15px;
left: 0;
position: absolute;
width: 10%;
}
ul.checkout-bar li {
display: inline-block;
margin: 50px 0 0;
padding: 0;
text-align: center;
width: 19%;
}
ul.checkout-bar li:before {
height: 70px;
left: 40%;
line-height: 70px;
position: absolute;
top: -80px;
width: 70px;
z-index: 99;
}
ul.checkout-bar li.visited {
background: none;
}
ul.checkout-bar li.visited:after {
background-size: 35px 35px;
background-color: #57aed1;
background-image: -webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent);
background-image: -moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent);
-webkit-box-shadow: inset 2px 2px 2px 0px rgba(0, 0, 0, 0.2);
box-shadow: inset 2px 2px 2px 0px rgba(0, 0, 0, 0.2);
content: "";
height: 15px;
left: 50%;
position: absolute;
top: -50px;
width: 100%;
z-index: 99;
}
}
<link href='http://fonts.googleapis.com/css?family=PT+Sans+Caption:400,700' rel='stylesheet' type='text/css'/>
<h1>Responsive Checkout Progress Bar</h1>
<div class="checkout-wrap">
<ul class="checkout-bar">
<li class="visited first">Possible candidate</li>
<li class="previous visited">Forwarded to manager</li>
<li class="active">Phone screen</li>
<li class="next">Interview</li>
<li class="">Complete</li>
<li class="">Cancelled</li>
</ul>
</div>
Ok, so I have a simple div with a height and width set.
Before and after also have height and width set.
They are all set to display as blocks, and the pseudo-elements have content "".
The :before is inside the content, not before it.
And the :after has a load of weird spacing before it.
HTML:
<div class="board">
Hi
</div>
CSS:
.board {
width: 260px; /*300 - 40*/
height: 400px; /*480 - 40 - 40*/
line-height: 400px;
color: #164d87;
font-size: 20px;
font-weight: 900;
margin: 0 auto;
background:
linear-gradient( 0deg,
rgba(2, 188, 226, 0.5) 0%,
rgba(51, 219, 253, 0.5) 25%,
rgba(51, 219, 253, 0.5) 75%,
rgba(2, 188, 226, 0.5) 100%
);
text-align: center;
border: 3px solid #2B2B2B;
}
.board:before, .board:after {
content: "";
display: block;
height: 40px;
width: 300px;
margin-left: -20px;
}
Codepen: http://codepen.io/MattCowley/pen/ZOQMNg
To keep existing markup, you can use position: absolute, and if you need the div to adjust to surrounding elements, give it a left/right margin matching the pseudo's width.
.board {
position: relative;
width: 260px; /*300 - 40*/
height: 400px; /*480 - 40 - 40*/
line-height: 400px;
color: #164d87;
font-size: 20px;
font-weight: 900;
margin: 40px auto 0;
background:
linear-gradient( 0deg,
rgba(2, 188, 226, 0.5) 0%,
rgba(51, 219, 253, 0.5) 25%,
rgba(51, 219, 253, 0.5) 75%,
rgba(2, 188, 226, 0.5) 100%
);
text-align: center;
border: 3px solid #2B2B2B;
}
.board:before, .board:after {
content: "";
position: absolute;
display: block;
height: 40px;
width: 100%;
background: red;
}
.board:before, .board:after {
bottom: calc(100% + 3px); /* 3px for the border */
}
.board:after {
top: calc(100% + 3px);
}
<div class="board">
Hi
</div>