css child before

Kompletter CSS Code:
@font-face {
font-family: "Courier Prime";
src: url("../font/CourierPrime-Bold.woff2") format("woff2"),
url("../font/CourierPrime-Bold.woff") format("woff"),
url("../font/CourierPrime-Bold.ttf") format("truetype");
font-weight: bold;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: "Courier Prime";
src: url("../font/CourierPrime-Italic.woff2") format("woff2"),
url("../font/CourierPrime-Italic.woff") format("woff"),
url("../font/CourierPrime-Italic.ttf") format("truetype");
font-weight: normal;
font-style: italic;
font-display: swap;
}
@font-face {
font-family: "Courier Prime";
src: url("../font/CourierPrime-BoldItalic.woff2") format("woff2"),
url("../font/CourierPrime-BoldItalic.woff") format("woff"),
url("../font/CourierPrime-BoldItalic.ttf") format("truetype");
font-weight: bold;
font-style: italic;
font-display: swap;
}
@font-face {
font-family: "Courier Prime";
src: url("../font/CourierPrime-Regular.woff2") format("woff2"),
url("../font/CourierPrime-Regular.woff") format("woff"),
url("../font/CourierPrime-Regular.ttf") format("truetype");
font-weight: normal;
font-style: normal;
font-display: swap;
}
:root {
--display: #fff;
--font: #000;
}
*,
::after,
::before {
box-sizing: border-box;
padding: 0;
margin: 0;
}
body,
html {
font-family: "Courier Prime", sans-serif;
background-color: var(--display);
color: var(--font);
}
/* BUTTON */
button {
background-color: #000;
padding: 1rem 2rem;
border: 2px solid #000;
margin-top: 1.5rem;
margin-bottom: 0.5rem;
}
button a {
text-decoration: none;
color: #fff;
font-size: 0.8rem;
}
small {
font-size: 15px;
}
h1 {
font-size: 3em;
letter-spacing: -0.06em;
}
h2 {
font-size: 2em;
letter-spacing: -0.06em;
margin-bottom: 1rem;
}
h3 {
font-size: 1.5em;
letter-spacing: -0.06em;
}
p,
li {
font-size: 16px;
line-height: 1.3;
position: relative;
list-style: none;
}
li {
position: relative;
padding: 0 0 0 2em;
}
li::before {
content: "\2713";
position: absolute;
width: 20px;
height: 20px;
margin-left: -2em;
color: lightgreen;
font-weight: bold;
}
section {
margin: 5rem 0;
}
.container {
display: flex;
flex-basis: 100%;
flex-wrap: wrap;
gap: 0 5rem;
max-width: 1400px;
margin: 0 auto;
padding: 1rem;
}
.container div {
flex: 1 1 0;
}
/* animated arrow header page */
.arrow {
position: absolute;
bottom: 5%;
left: 50%;
transform: translate(-50%, -50%);
cursor: pointer;
}
.arrow span {
display: block;
width: 30px;
height: 30px;
border-bottom: 5px solid #000;
border-right: 5px solid #000;
transform: rotate(45deg);
margin: -10px;
animation: scroll 2s infinite;
}
.arrow span:nth-child(2) {
animation-delay: -0.2s;
}
.arrow span:nth-child(3) {
animation-delay: -0.4s;
}
@keyframes scroll {
0% {
opacity: 0;
transform: rotate(45deg) translate(-20px, -20px);
}
50% {
opacity: 1;
transform: rotate(45deg) translate(-20px, -20px);
}
100% {
opacity: 0;
transform: rotate(45deg) translate(20px, 20px);
}
}
/* animated arrow header page end */
/* MEDIA SCREEN 1000px */
@media screen and (max-width: 1000px) {
.container {
display: flex;
flex-basis: 100%;
flex-wrap: wrap;
}
.container div {
flex: 1 1 100%;
}
section {
margin: 3rem 0;
}
.imghtml img {
padding: 2rem;
}
}
/* TOPBAR */
/* .topbar {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
float: inline-end;
padding: 1rem 1rem;
background-color: #ccc;
} */
/* NAVIGATION */
.navbar {
width: 100%;
background-color: #000;
}
.nav-container {
display: flex;
justify-content: space-between;
align-items: center;
height: 62px;
max-width: 1520px;
margin: 0 auto;
z-index: 999;
}
.navbar .menu-items {
display: flex;
}
/* .navbar .nav-container li {
list-style: none;
} */
.navbar .nav-container a {
text-decoration: none;
color: #fff;
font-weight: 500;
font-size: 1.2rem;
padding: 0.7rem;
}
.navbar .nav-container a:hover {
font-weight: bolder;
}
.nav-container {
display: block;
position: relative;
height: 60px;
}
.nav-container .checkbox {
position: absolute;
display: block;
height: 32px;
width: 32px;
top: 20px;
right: 20px;
z-index: 5;
opacity: 0;
cursor: pointer;
}
.nav-container .hamburger-lines {
display: block;
height: 26px;
width: 32px;
position: absolute;
top: 17px;
right: 20px;
z-index: 2;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.nav-container .hamburger-lines .line {
display: block;
height: 4px;
width: 100%;
border-radius: 10px;
background: #fff;
}
.nav-container .hamburger-lines .line1 {
transform-origin: 0% 0%;
transition: transform 0.4s ease-in-out;
}
.nav-container .hamburger-lines .line2 {
transition: transform 0.2s ease-in-out;
}
.nav-container .hamburger-lines .line3 {
transform-origin: 0% 100%;
transition: transform 0.4s ease-in-out;
}
.navbar .menu-items {
background-color: #000;
height: 100vh;
width: 100%;
transform: translate(-150%);
display: flex;
flex-direction: column;
padding-top: 10rem;
margin-right: -40px;
transition: transform 0.5s ease-in-out;
text-align: center;
list-style: none;
}
.navbar .menu-items p {
margin-bottom: 1.2rem;
font-size: 2em;
font-weight: 500;
list-style: none;
}
.logo {
position: absolute;
top: 5px;
left: 15px;
font-size: 1.5rem;
color: #fff;
}
.logo > span {
font-size: 1rem;
}
.nav-container input[type="checkbox"]:checked ~ .menu-items {
transform: translateX(0);
}
.nav-container input[type="checkbox"]:checked ~ .hamburger-lines .line1 {
transform: rotate(45deg);
}
.nav-container input[type="checkbox"]:checked ~ .hamburger-lines .line2 {
transform: scaleY(0);
}
.nav-container input[type="checkbox"]:checked ~ .hamburger-lines .line3 {
transform: rotate(-45deg);
}
.nav-container input[type="checkbox"]:checked ~ .logo {
display: none;
}
/* HEADER */
header {
background: radial-gradient(
rgba(0, 0, 0, 0.1),
rgba(255, 255, 255, 1),
rgb(255, 255, 255)
);
height: 100vh;
display: flex;
align-items: center;
text-align: center;
padding: 0 1rem;
}
.header-center {
max-width: 50rem;
margin: 0 auto;
}
h1 span {
font-size: 3rem;
position: relative;
z-index: 1000;
}
h1 span:nth-child(1)::before {
content: "";
position: absolute;
background-color: lightgreen;
top: 35px;
width: 100%;
height: 20px;
z-index: -1;
}
h1 span:nth-child(2)::before {
content: "";
position: absolute;
background-color: lightgreen;
top: 35px;
width: 100%;
height: 20px;
}
/* 1# Abschnitt */
.bg-black {
background-color: #000;
color: #fff;
width: 100%;
padding: 1rem 2rem;
}
.images {
display: flex;
justify-content: center;
}
.images img {
max-width: 100%;
height: 100%;
}
.bg-black .container {
display: flex;
align-items: center;
}
.bg-black small {
color: lightgreen;
}
/* 2# Abschnitt */
.imghtml {
display: flex;
justify-content: center;
height: 30vh;
}
.imghtml img {
max-width: 100%;
height: 100%;
}
/* 4# Abschnitt */
.box {
display: flex;
flex-direction: column;
text-align: center;
}
.box img {
width: 80px;
height: 80px;
padding: 1rem;
margin: 0 auto;
}
.box p:first-of-type {
background-color: #000;
color: lightgreen;
font-size: 22px;
margin-bottom: 0.5rem;
padding: 0.2rem;
}
Ergänzung ()

das hat jetzt funktioniert bei mir

h1 span {
font-size: 3rem;
position: relative;
z-index: 1000;
}
h1 span:nth-child(1)::before {
content: "";
position: absolute;
background-color: lightgreen;
top: 35px;
width: 100%;
height: 20px;
z-index: -1;
}
h1 span:nth-child(2)::after {
content: "";
position: absolute;
background-color: lightgreen;
top: 35px;
left: 0;
width: 100%;
height: 20px;
z-index: -1;
}
Ergänzung ()

statt ::before halt ::after und es funktioniert
 
Zuletzt bearbeitet:
Defacto muss
CSS:
h1 span::before
funktionieren! Wenn du Code komplett doppelt hast, machst du was falsch!
Und macht du eigentlich keinerlei Codeeinrückungen? Liest sich ja grauenhaft!
 
Zuletzt bearbeitet:
@aronlad ich weiß.. doch doch.. hats wohl nicht übernommen programmier in vscode mit prettier..
ich lass es jetzt mal mit ::after, vielleicht fällt mir mit der zeit eine andere lösung ein.. inzwischen soll mal das styling hinhauen
 
achso.. hm.. damit hab ich mich jetzt nicht beschäftigt.. ich habe jetzt das logische genommen.. wenn ich zeit habe kann ich mich ja damit spielen
 
Zurück
Oben