This question already has answers here:
Does UL have default margin or padding [duplicate]
(2 answers)
Closed 1 year ago.
I have made a div and assigned display grid to it everything is fine but the problem is there is a margin I don't know if its a code that i wrote wrong or sthg else .. i tried to use margin : 0 auto; but didn't work it made it worse actually xD. i also checked if the container has margin or padding
Here is what am i talking about :
$('#owl-carousel').owlCarousel({
loop: true,
margin: 30,
dots: true,
nav: false,
rtl: true,
items: 2,
})
.text {
text-align: center;
height: 100px;
background: #0b0a0d;
color: #FFF;
}
.text .logo a{
margin: 0;
line-height: 100px;
font-size: 48px;
font-family: 'Zen Dots', cursive;}
.nav {
background: #0c70de;
color: #FFF;
display: flex;
z-index: 9999;
}
.text .logo a{
color: #FFF;
text-decoration: none
}
.nav ul {
margin: 0 auto;
padding: 0;
display: flex;
/* width: 50%; */
/* margin-left: auto; */
}
ul li{
padding: 20px;
list-style: none
}
ul li a{
color: #FFF;
display: block;
text-decoration: none;
text-transform: uppercase;
font-family: 'Changa', sans-serif;
}
.sticky{
position: fixed;
top: 0;
left: 0;
width: 100%
}
.contain {
margin: 0 auto;
max-width: 1200px;
width: 100%;
margin-top: 50px;
}
.item {
align-items: center;
display: flex;
height: 300px;
justify-content: center;
}
/* slider */
#import url('https://fonts.googleapis.com/css?family=Raleway:100,400');
body {
font-family: 'Raleway', sans-serif;
font-weight: thin;
background: black;
margin: 0;
padding: 0;
}
body:after{
content: "";
display: block;
position: fixed;
top: 0;
left: 0;
margin: 0;
z-index: -1;
width: 200%;
height: 200%;
background-color: #16151d;
}
.movie-card {
position: relative;
box-sizing: border-box;
width: 100%;
max-width: 800px;
height: 300px;
background-position: center;
background-size: cover;
margin: 4vh auto;
border-radius: 4px;
box-shadow: 2px 3px 12px rgba(0, 0, 0, .4);
color: white;
padding: 2vh 3%;
}
.movie-card:after{
content: "";
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 4px;
background: linear-gradient(to left, rgba(40,40,60,1) 0%,rgba(40,0,60,0) 90%);
background-blend-mode: multiply;
will-change: transform;
z-index: 0;
}
i {
font-size: .7em;
color: #ff5b84;
}
h1 {
font-size: 170%;
position: relative;
z-index: 10;
}
span {
display: inline-block;
position: relative;
z-index: 10;
margin-right: 80px;
color: rgb(210, 210, 210);
}
.watch {
display: block;
border: 1px solid white;
border-radius: 4px;
position: relative;
z-index: 10;
color: white;
padding: 10px;
text-align: center;
background: rgba(0, 0, 0, .3);
margin: 20px 0px;
outline: none;
box-shadow: 0 0 10px rgba(0,0,0,.5);
transition: all .2s;
}
button:hover {
background: rgba(255, 255, 255, .8);
color: black;
box-shadow: 0 0 10px rgba(255,255,255,.5);
mix-blend-mode: screen;
}
button:active {
transform: translateY(2px);
}
p {
position: relative;
z-index: 10;
font-size: .8em;
width: 60%;
height: 35%;
}
#media (max-width: 768px) {
body {
/* background: none; */
}
.movie-card {
width: 75%;
height: 200px;
}
h1 {
font-size: 120%;
}
p {
display: none;
/* overflow: hidden;
width: 100%;
height: 30%; */
}
.watch {
margin: 5% auto;
}
}
#media (max-width: 500px) {
.movie-card {
width: 100%;
}
}
.hot {
background-color: #694ba1;
padding: 8px 15px;
border-top-right-radius: 3px;
border-top-left-radius: 3px;
}
.hot h3 {
color: #FFF;
}
h3 {
font-size: 1.1em;
line-height: 20px;
font-weight: 500;
margin: 0;
position: relative;
}
.anime-list {
background-color: #222;
}
/*
AUTO GRID
Set the minimum item size with `--auto-grid-min-size` and you'll
get a fully responsive grid with no media queries.
*/
.auto-grid {
--auto-grid-min-size: 16rem;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(var(--auto-grid-min-size), 1fr));
grid-gap: 1rem;
}
/* Presentational styles */
.anime-list ul li {
padding: 5rem 1rem;
text-align: center;
font-size: 1.2rem;
background-size: cover;
background-position: center;
}
.anime-list {
align-items: center;
}
<!DOCTYPE html>
<html dir="rtl">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>owl</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.3/animate.min.css">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Zen+Dots&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Changa:wght#500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.css">
</head>
<body>
<!-- * Header START -->
<div class="text">
<div class="logo">
ON ANIME
</div>
</div>
<div class="nav">
<ul>
<li>الرئيسية</li>
<li>قائمة الانميات</li>
<li>افلام الانمي</li>
</ul>
</div>
<div class="contain">
<div id="owl-carousel" class="owl-carousel owl-theme">
<div class="item">
<div class="movie-card" style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://images3.alphacoders.com/820/thumb-1920-820754.png");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://images3.alphacoders.com/820/thumb-1920-820754.png");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://images3.alphacoders.com/820/thumb-1920-820754.png");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://images3.alphacoders.com/820/thumb-1920-820754.png");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
</div>
</div>
<div class="contain">
<div class="postss">
<div class="hot">
<h3>انميات مميزة</h3>
</div>
<div class="anime-list">
<ul class="auto-grid">
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 1</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 2</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 3</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 4</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 5</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 6</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 7</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 8</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 9</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 10</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 11</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 12</li>
</ul>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.js"></script>
<script src="script.js" async defer></script>
</body>
</html>
You need to over wright the default of the grid ul
So I added ul {padding-inline-start: 0px;} and it seems to be fixed
$('#owl-carousel').owlCarousel({
loop: true,
margin: 30,
dots: true,
nav: false,
rtl: true,
items: 2,
})
ul {padding-inline-start: 0px;}
.text {
text-align: center;
height: 100px;
background: #0b0a0d;
color: #FFF;
}
.text .logo a{
margin: 0;
line-height: 100px;
font-size: 48px;
font-family: 'Zen Dots', cursive;}
.nav {
background: #0c70de;
color: #FFF;
display: flex;
z-index: 9999;
}
.text .logo a{
color: #FFF;
text-decoration: none
}
.nav ul {
margin: 0 auto;
padding: 0;
display: flex;
/* width: 50%; */
/* margin-left: auto; */
}
ul li{
padding: 20px;
list-style: none
}
ul li a{
color: #FFF;
display: block;
text-decoration: none;
text-transform: uppercase;
font-family: 'Changa', sans-serif;
}
.sticky{
position: fixed;
top: 0;
left: 0;
width: 100%
}
.contain {
margin: 0 auto;
max-width: 1200px;
width: 100%;
margin-top: 50px;
}
.item {
align-items: center;
display: flex;
height: 300px;
justify-content: center;
}
/* slider */
#import url('https://fonts.googleapis.com/css?family=Raleway:100,400');
body {
font-family: 'Raleway', sans-serif;
font-weight: thin;
background: black;
margin: 0;
padding: 0;
}
body:after{
content: "";
display: block;
position: fixed;
top: 0;
left: 0;
margin: 0;
z-index: -1;
width: 200%;
height: 200%;
background-color: #16151d;
}
.movie-card {
position: relative;
box-sizing: border-box;
width: 100%;
max-width: 800px;
height: 300px;
background-position: center;
background-size: cover;
margin: 4vh auto;
border-radius: 4px;
box-shadow: 2px 3px 12px rgba(0, 0, 0, .4);
color: white;
padding: 2vh 3%;
}
.movie-card:after{
content: "";
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 4px;
background: linear-gradient(to left, rgba(40,40,60,1) 0%,rgba(40,0,60,0) 90%);
background-blend-mode: multiply;
will-change: transform;
z-index: 0;
}
i {
font-size: .7em;
color: #ff5b84;
}
h1 {
font-size: 170%;
position: relative;
z-index: 10;
}
span {
display: inline-block;
position: relative;
z-index: 10;
margin-right: 80px;
color: rgb(210, 210, 210);
}
.watch {
display: block;
border: 1px solid white;
border-radius: 4px;
position: relative;
z-index: 10;
color: white;
padding: 10px;
text-align: center;
background: rgba(0, 0, 0, .3);
margin: 20px 0px;
outline: none;
box-shadow: 0 0 10px rgba(0,0,0,.5);
transition: all .2s;
}
button:hover {
background: rgba(255, 255, 255, .8);
color: black;
box-shadow: 0 0 10px rgba(255,255,255,.5);
mix-blend-mode: screen;
}
button:active {
transform: translateY(2px);
}
p {
position: relative;
z-index: 10;
font-size: .8em;
width: 60%;
height: 35%;
}
#media (max-width: 768px) {
body {
/* background: none; */
}
.movie-card {
width: 75%;
height: 200px;
}
h1 {
font-size: 120%;
}
p {
display: none;
/* overflow: hidden;
width: 100%;
height: 30%; */
}
.watch {
margin: 5% auto;
}
}
#media (max-width: 500px) {
.movie-card {
width: 100%;
}
}
.hot {
background-color: #694ba1;
padding: 8px 15px;
border-top-right-radius: 3px;
border-top-left-radius: 3px;
}
.hot h3 {
color: #FFF;
}
h3 {
font-size: 1.1em;
line-height: 20px;
font-weight: 500;
margin: 0;
position: relative;
}
.anime-list {
background-color: #222;
}
/*
AUTO GRID
Set the minimum item size with `--auto-grid-min-size` and you'll
get a fully responsive grid with no media queries.
*/
.auto-grid {
--auto-grid-min-size: 16rem;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(var(--auto-grid-min-size), 1fr));
grid-gap: 1rem;
}
/* Presentational styles */
.anime-list ul li {
padding: 5rem 1rem;
text-align: center;
font-size: 1.2rem;
background-size: cover;
background-position: center;
}
.anime-list {
align-items: center;
}
<!DOCTYPE html>
<html dir="rtl">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>owl</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.3/animate.min.css">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Zen+Dots&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Changa:wght#500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.css">
</head>
<body>
<!-- * Header START -->
<div class="text">
<div class="logo">
ON ANIME
</div>
</div>
<div class="nav">
<ul>
<li>الرئيسية</li>
<li>قائمة الانميات</li>
<li>افلام الانمي</li>
</ul>
</div>
<div class="contain">
<div id="owl-carousel" class="owl-carousel owl-theme">
<div class="item">
<div class="movie-card" style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://images3.alphacoders.com/820/thumb-1920-820754.png");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://images3.alphacoders.com/820/thumb-1920-820754.png");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://images3.alphacoders.com/820/thumb-1920-820754.png");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://images3.alphacoders.com/820/thumb-1920-820754.png");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
</div>
</div>
<div class="contain">
<div class="postss">
<div class="hot">
<h3>انميات مميزة</h3>
</div>
<div class="anime-list">
<ul class="auto-grid">
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 1</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 2</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 3</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 4</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 5</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 6</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 7</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 8</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 9</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 10</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 11</li>
<li style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");">Item 12</li>
</ul>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.js"></script>
<script src="script.js" async defer></script>
</body>
</html>
Related
am a bit confused why doesn't div background contain the text under the image... i tried to use more padding for the text but also didn't work what am I trying to do here is to align the text under the image and also make the text have the same background as the "cardo" div have .. i tried similar codes but nothing if someone can help me here I would be so thankful.
$('#owl-carousel').owlCarousel({
loop: true,
margin: 30,
dots: true,
nav: false,
rtl: true,
items: 2,
})
.text {
text-align: center;
height: 100px;
background: #0b0a0d;
color: #FFF;
}
.text .logo a{
margin: 0;
line-height: 100px;
font-size: 48px;
font-family: 'Zen Dots', cursive;}
.nav {
background: #0c70de;
color: #FFF;
display: flex;
z-index: 9999;
}
.text .logo a{
color: #FFF;
text-decoration: none
}
.nav ul {
margin: 0 auto;
padding: 0;
display: flex;
/* width: 50%; */
/* margin-left: auto; */
}
ul li{
padding: 20px;
list-style: none
}
ul li a{
color: #FFF;
display: block;
text-decoration: none;
text-transform: uppercase;
font-family: 'Changa', sans-serif;
}
.sticky{
position: fixed;
top: 0;
left: 0;
width: 100%
}
.contain {
margin: 0 auto;
max-width: 1200px;
width: 100%;
margin-top: 50px;
}
.item {
align-items: center;
display: flex;
height: 300px;
justify-content: center;
}
/* slider */
#import url('https://fonts.googleapis.com/css?family=Raleway:100,400');
body {
font-family: 'Raleway', sans-serif;
font-weight: thin;
background: black;
margin: 0;
padding: 0;
}
body:after{
content: "";
display: block;
position: fixed;
top: 0;
left: 0;
margin: 0;
z-index: -1;
width: 200%;
height: 200%;
background-color: #16151d;
}
.movie-card {
position: relative;
box-sizing: border-box;
width: 100%;
max-width: 800px;
height: 300px;
background-position: center;
background-size: cover;
margin: 4vh auto;
border-radius: 4px;
box-shadow: 2px 3px 12px rgba(0, 0, 0, .4);
color: white;
padding: 2vh 3%;
}
.movie-card:after{
content: "";
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 4px;
background: linear-gradient(to left, rgba(40,40,60,1) 0%,rgba(40,0,60,0) 90%);
background-blend-mode: multiply;
will-change: transform;
z-index: 0;
}
i {
font-size: .7em;
color: #ff5b84;
}
h1 {
font-size: 170%;
position: relative;
z-index: 10;
}
span {
display: inline-block;
position: relative;
z-index: 10;
margin-right: 80px;
color: rgb(210, 210, 210);
}
.watch {
display: block;
border: 1px solid white;
border-radius: 4px;
position: relative;
z-index: 10;
color: white;
padding: 10px;
text-align: center;
background: rgba(0, 0, 0, .3);
margin: 20px 0px;
outline: none;
box-shadow: 0 0 10px rgba(0,0,0,.5);
transition: all .2s;
}
button:hover {
background: rgba(255, 255, 255, .8);
color: black;
box-shadow: 0 0 10px rgba(255,255,255,.5);
mix-blend-mode: screen;
}
button:active {
transform: translateY(2px);
}
p {
position: relative;
z-index: 10;
font-size: .8em;
width: 60%;
height: 35%;
}
#media (max-width: 768px) {
body {
/* background: none; */
}
.movie-card {
width: 75%;
height: 200px;
}
h1 {
font-size: 120%;
}
p {
display: none;
/* overflow: hidden;
width: 100%;
height: 30%; */
}
.watch {
margin: 5% auto;
}
}
#media (max-width: 500px) {
.movie-card {
width: 100%;
}
}
.hot {
background-color: #694ba1;
padding: 8px 15px;
border-top-right-radius: 3px;
border-top-left-radius: 3px;
}
.hot h3 {
color: #FFF;
}
h3 {
font-size: 1.1em;
line-height: 20px;
font-weight: 500;
margin: 0;
position: relative;
}
.anime-list {
background-color: #222;
}
.cardo {
background-size: cover;
background-position: center;
color: white;
height: 10rem;
margin: 8px;
vertical-align: top;
display: inline-block;
text-align: center;
}
.cardo img {
width: 100%;
height: 100%;
}
.caption {
position: relative;
bottom: 0;
}
.cards {
max-width: 1200px;
margin: 0 auto;
display: grid;
}
/* Screen larger than 600px? 2 column */
#media (min-width: 600px) {
.cards { grid-template-columns: repeat(2, 1fr); }
}
/* Screen larger than 900px? 3 columns */
#media (min-width: 900px) {
.cards { grid-template-columns: repeat(5, 1fr); }
}
<!DOCTYPE html>
<html dir="rtl">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>owl</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.3/animate.min.css">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Zen+Dots&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Changa:wght#500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.css">
</head>
<body>
<!-- * Header START -->
<div class="text">
<div class="logo">
ON ANIME
</div>
</div>
<div class="nav">
<ul>
<li>الرئيسية</li>
<li>قائمة الانميات</li>
<li>افلام الانمي</li>
</ul>
</div>
<div class="contain">
<div id="owl-carousel" class="owl-carousel owl-theme">
<div class="item">
<div class="movie-card" style="background-image: url("https://images3.alphacoders.com/820/thumb-1920-820754.png");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://images3.alphacoders.com/820/thumb-1920-820754.png");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://images3.alphacoders.com/820/thumb-1920-820754.png");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://images3.alphacoders.com/820/thumb-1920-820754.png");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://images3.alphacoders.com/820/thumb-1920-820754.png");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
<div class="item">
<div class="movie-card" style="background-image: url("https://wallpaperaccess.com/full/2412138.jpg");"><h1>The Incredibles 2</h1><span>92 min</span><span>5 <i class="fas fa-star"></i></span><p>Helen is called on to lead a campaign to bring Supers back, while Bob navigates the day-to-day heroics of 'normal' life at home with Violet, Dash and baby Jack-Jack - whose superpowers are about to be discovered.</p><button class="watch">WATCH MOVIE</button></div>
</div>
</div>
</div>
<div class="contain">
<div class="postss">
<div class="hot">
<h3>انميات مميزة</h3>
</div>
<div class="anime-list">
<div class="cards">
<div class="cardo">
<img src="https://wallpaperaccess.com/full/2412138.jpg">
<div class="caption">
my text
</div>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.js"></script>
<script src="script.js" async defer></script>
</body>
</html>
The problem is in your image style. You shouldn't use both width and height because it stretches the image and you should use 90% for the height to leave space for the text.
.cardo img {
height: 90%;
}
I'm building a responsive site and I'm using overflow-x: hidden property to stop the page from scrolling horizontally and showing white space but it's not working on phones. Every time I navigate back to the page, the horizontal scrollbar is shown again and white space appears on the right. I have looked at various other questions on this issue but cannot seem to solve it.
I believe it is related to the cards on the page, is any of the styling on the cards causing this issue? How can I remove the white space?
html {
overflow-x: hidden;
}
.portfolio-header {
margin-top: 19rem;
margin-left: 31%;
font-size: 30px;
}
}
.card-square
{
position: relative;
width: 90%;
height: 300px;
display: flex;
margin-left: 0px;
margin-top: 50px;
margin-bottom: 100px;
justify-content: center;
align-items: center;
}
.card-square-2 {
margin-top: 0rem;
}
.card-square span:nth-child(1) {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 2px solid #000;
border-radius: 38% 62% 63% 37% /
41% 44% 56% 59%;
transition: 0.5s;
animation: animate 6s linear infinite;
}
.card-square:hover span:nth-child(1) {
border: none;
background: rgba(22,168,194,0.8);
}
.card-square span:nth-child(2) {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 2px solid #000;
border-radius: 38% 62% 63% 37% /
41% 44% 56% 59%;
transition: 0.5s;
animation: animate2 4s linear infinite;
}
.card-square:hover span:nth-child(2) {
border: none;
background: rgba(22,168,194,0.8);
}
.card-square span:nth-child(3) {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 2px solid #000;
border-radius: 38% 62% 63% 37% /
41% 44% 56% 59%;
transition: 0.5s;
animation: animate 10s linear infinite;
}
.card-square:hover span:nth-child(3) {
border: none;
background: rgba(22,168,194,0.8);
}
#keyframes animate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
#keyframes animate2 {
0% {
transform: rotate(360deg);
}
100% {
transform: rotate(0deg);
}
}
.content {
position: relative;
color: #000;
text-align: center;
transition: 0.5s;
z-index: 1000;
}
.content a {
position: relative;
/* display: inline-block; */
margin-top: 10px;
border: 2px solid #fff;
padding: 6px 18px;
text-decoration: none;
color: #fff;
margin-left: 12px;
font-weight: 600;
border-radius: 73% 27% 44% 56% /
49% 44% 56% 51%;
}
.content a:hover {
background: #000;
color: #333;
}
.content p, .content h2 {
text-align: center;
width: 85%;
margin-left: 7.5%;
}
.content p {
font-size: 16px;
}
#media only screen and (min-width: 768px) {
.card-square {
width: 400px;
height: 400px;
margin-left: 130px;
}
.card-square-2 {
margin-top: -500px;
margin-left: 55%;
}
.card-square-4 {
margin-left: 55%;
margin-top: -500px;
}
.content p {
font-size: 20px;
}
}
<section class="portfolio" id="portfolio">
<h1 class="portfolio-header">Card section</h1>
<div class="card-square">
<span></span>
<span></span>
<span></span>
<div class="content">
<h2>Card 1</h2>
<p> This is card 1.
</p>
Link btn
</div>
</div>
<div class="card-square card-square-2">
<span></span>
<span></span>
<span></span>
<div class="content">
<h2>Card 2</h2>
<p>This is card 2. </p>
Link
</div>
</div>
<div class="card-square card-square-3">
<span></span>
<span></span>
<span></span>
<div class="content">
<h2>Card 3</h2>
<p>This is card 3.</p>
Link
<a class="second-btn" href="#">Link 2</a>
</div>
</div>
<div class="card-square card-square-4">
<span></span>
<span></span>
<span></span>
<div class="content">
<h2>Card 4</h2>
<p>This is card 4.</p>
Link 4
</div>
</div>
</section>
It's because you use width: 100vw - if you have a vertical scroll, your vw will not take the scrollbar into account and will give you horizontal scroll too. Use width: 100% instead (or remove it as h2 is a block element and will take the full width anyway)
html,
body {
margin: 0;
min-height: 100%;
min-width: 100%;
}
body {
margin: 0;
padding: 0;
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
}
section {
margin-bottom: -33px;
}
h1 {
margin-left: 20%;
color: rgb(22, 168, 194);
}
/* Hero Image & navbar */
.banner-text {
width: 100%;
position: absolute;
}
* {
box-sizing: border-box;
}
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
background-color: none;
color: white;
font-size: 20px;
}
.navbar-links ul {
margin: 0;
padding: 0;
display: flex;
}
.navbar-links li {
list-style: none;
}
.navbar-links li a {
text-decoration: none;
color: white;
padding-left: 1rem;
padding-right: 1em;
display: block;
}
.navbar-links li:hover {
background: #555;
}
.toggle-button {
position: absolute;
top: .75rem;
right: 2.5rem;
display: none;
flex-direction: column;
justify-content: space-between;
width: 31px;
height: 21px;
}
/* Phones */
#media (min-width: 320px) and (max-width: 480px) {
.toggle-button {
display: flex;
}
.navbar-links li:hover {
background: #555;
}
.navbar-links {
display: none;
width: 100%;
}
.navbar {
flex-direction: column;
align-items: flex-start;
}
.navbar-links ul {
flex-direction: column;
width: 100%;
/* margin-top: 30px; */
}
.navbar-links li {
text-align: center;
}
.navbar-links li .navlink {
padding: 0.5rem 1rem;
}
.navbar-links.active {
display: flex;
}
}
.toggle-button .bar {
height: 3px;
width: 100%;
background: white;
border-radius: 10px;
}
.banner-text h2 {
text-align: center;
color: #fff;
width: 100%;
font-size: 28px;
margin-top: 48%;
}
.banner-text .name {
margin-bottom: -95px;
}
/* For desktop: */
#media only screen and (min-width: 768px) {
.banner-text h2 {
margin-top: 14%;
font-size: 54px;
}
.banner-text .name {
margin-bottom: -100px;
}
}
.animation-area {
/* background: linear-gradient(to left, #16A8C2, #1B1C1C); */
background: rgb(22, 168, 194);
background: linear-gradient(0deg, rgba(22, 168, 194, 1) 0%, rgba(27, 28, 28, 1) 100%);
width: 100%;
height: 100vh;
}
.box-area {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 97%;
overflow: hidden;
}
.box-area .box-item {
position: absolute;
display: block;
list-style: none;
width: 25px;
height: 25px;
background: rgba(255, 255, 255, 0.2);
animation: animatedSquares 20s linear infinite;
bottom: -150px;
}
.box-area li:nth-child(1) {
left: 86%;
width: 80px;
height: 80px;
animation-delay: 0s
}
.box-area li:nth-child(2) {
left: 12%;
width: 30px;
height: 30px;
animation-delay: 1.5s;
animation-duration: 10s;
}
.box-area li:nth-child(3) {
left: 70%;
width: 100px;
height: 100px;
animation-duration: 5.5s;
}
.box-area li:nth-child(4) {
left: 42%;
width: 150px;
height: 150px;
animation-delay: 0s;
animation-duration: 15s;
}
.box-area li:nth-child(5) {
left: 65%;
width: 40px;
height: 40px;
animation-delay: 0s;
}
.box-area li:nth-child(6) {
left: 15%;
width: 110px;
height: 110px;
animation-delay: 3.5s;
}
#keyframes animatedSquares {
0% {
transform: translateY(0) rotate(0deg);
opacity: 1;
}
100% {
transform: translateY(-800px) rotate(360deg);
opacity: 0;
}
}
<section>
<div class="banner-text">
<nav class="navbar">
<a href="#" class="toggle-button">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</a>
<div class="navbar-links">
<ul>
<li><a class="navlink" href="#">navlink1</a></li>
<li><a class="navlink" href="#">navlink2</a></li>
<li><a class="navlink" href="#">navlink3</a></li>
<li><a class="navlink" href="#">navlink4">CV</a></li>
</ul>
</div>
</nav>
<h2 class="header name">title name</h2>
<h2 class="header role">title role</h2>
</div>
<div class="animation-area">
<ul class="box-area">
<li class="box-item"></li>
<li class="box-item"></li>
<li class="box-item"></li>
<li class="box-item"></li>
<li class="box-item"></li>
<li class="box-item"></li>
</ul>
</div>
</section>
<section class="about" id="about">
<!-- social media icon bar -->
<ul class="social-media">
<li class="social-item">
<a href="" class="github">
<i class="fa fa-github"></i></a>
</li>
<li class="social-item">
<a href="">
<i class="fa fa-linkedin"></i></a>
</li>
<li class="social-item">
<a href="">
<i class="fa fa-stack-overflow"></i></a>
</li>
</ul>
<ul class="social-media-2">
<li class="social-item">
<a href="" class="codepen">
<i class="fa fa-codepen"></i></a>
</li>
<li class="social-item">
<a href="" class="dribble">
<i class="fa fa-dribbble"></i></a>
</li>
<li class="social-item">
<a href="" class="twitter">
<i class="fa fa-twitter"></i></a>
</li>
</ul>
<h1 class="about-header">About</h1>
<p class="about-text">text
</p>
<p class="career-story">
text
</p>
<div class="polaroid">
<img class="work-colleagues" src="./Images/img.jpg" alt="alt">
<div class="description">
<p class="description-text">text
<a class="featured-link" href="link" width="100%" height="100%">
Polaroid text</a> </p>
</div>
</div>
<p class="interests">
text
</p>
<div class="polaroid polaroid-2">
<img src="./Images/img.jpg" alt="alt" width="100%" height="100%">
<div class="description">
<p class="description-text">text
</p>
</div>
</div>
</section>
You are on the right track, but one thing to keep in mind is that you need to also add meta tags to your HTML header.
Solution
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0, minimum-scale=1, maximum-scale=1">
And of course, in the CSS specify the overflow behavior:
html {
overflow-x: hidden;
}
Explanation
I'll break down the meta tag:
width=device-width this means we are telling the browser to adjust to the device-width
width=minimum-scale this is the smallest scale that you should go
width=maximum-scale this is the biggest scale that you should go
width=initial-scale where to start
user-scalable to allow the user to pinch (zoom in on mobile) or not.
You can read more about it on w3schools.
I found the reason why it's behaving like this.
You have the header and main content in a single section.
This caused all the issues.
Always try to segregate section wisely
Once you segregate. you can see the cards displaying in center.
later adjust your margin-left for .card-square class.
I haven't changed your CSS. Just modified your HTML to segregate the sections. now I cant see white space in the mobile view.
<section class="portfolio" id="portfolio">
<h1 class="portfolio-header">Card section</h1>
</section><section>
<div class="card-square">
<span></span>
<span></span>
<span></span>
<div class="content">
<h2>Card 1</h2>
<p> This is card 1.
</p>
Link btn
</div>
</div>
<div class="card-square card-square-2">
<span></span>
<span></span>
<span></span>
<div class="content">
<h2>Card 2</h2>
<p>This is card 2. </p>
Link
</div>
</div>
<div class="card-square card-square-3">
<span></span>
<span></span>
<span></span>
<div class="content">
<h2>Card 3</h2>
<p>This is card 3.</p>
Link
<a class="second-btn" href="#">Link 2</a>
</div>
</div>
<div class="card-square card-square-4">
<span></span>
<span></span>
<span></span>
<div class="content">
<h2>Card 4</h2>
<p>This is card 4.</p>
Link 4
</div>
</div>
</section>
I have an H2 (id=cover) which I'd like to stay centered and higher up in a background image, but as the page size shrinks it eventually drops to the bottom of the image, then falls off of it on my mobile android phone. Any help would be appreciated. Here is the code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Johnson Landscaping</title>
<link rel="stylesheet" href="style.css">
</head>
<div id="container">
<header>
<h1>Johnson Landscaping</h1>
<nav>
<ul class="menu">
<li>home</li>
<li>contact us</li>
</ul>
</nav>
</header>
<div>
<div class="image">
<img src="images/background-backlight-blur-color-262713.jpg" alt="" />
<h2 id="cover"><span>Quality Garden Care on the North Shore</span></h2>
</div>
<h2>Services</h2>
<div class="Services">
<h4>Garden Maintenance</h4>
<img src="images/person-holding-a-green-plant-1072824.jpg" alt="person holding green
plant">
<p>Enter Details</p>
</div>
<div class="Services">
<h4>Garden Design</h4>
<img src="images/blade-of-grass-depth-of-field-environment-garden-580900.jpg" alt="blades of
grass">
<p>Enter Details</p>
</div>
<div class="Services">
<h4>Tree and Shrub Pruning</h4>
<img src="images/apple-tree-6035.jpg" alt="apple tree">
<p>Enter Details</p>
</div>
<div class="Services">
<h4>Pressure Washing</h4>
<img src="images/photography-of-bricks-covered-with-moss-1089280.jpg" alt="bricks
covered in moss">
<p>Enter Details</p>
</div>
</main>
</div>
<footer>
<nav>
<ul>
<li>home</li>
<li>contact us</li>
</ul>
</nav>
</footer>
</body>
</html>
and css to go with it
html {
background: #f7f7f7;
color: #7cae49;
font-family: 'garamond', sans-serif;
}
body {
background: white;
margin: 0 auto;
font-family: 'garamond', sans-serif;
color: rgb(49, 46, 46);
text-align: center;
}
h1 {
float: none;
display: inline-block;
color: #5c7e3a;
width: 100%;
font-size: 50px;
text-align: center;
}
nav, li {
display: inline-block;
}
header, footer {
background: #DAF7A6;
color: #7cae49;
border-radius: 10px;
}
footer {
text-align: center;
padding: 30px 20px;
}
li {
list-style: none;
line-height: 20px;
font-size: 40px;
padding-right: 20px;
padding-top: 5px;
}
.image {
position: relative;
height: 60;
width: 100%;
margin: 0 auto;
border-radius: 10px;
}
#cover {
position: absolute;
top: 200px;
width: 100%;
color: white;
text-align: center;
vertical-align: middle;
display: flex, inline-block;
font-size: 20px;
}
a {
text-decoration: none;
color: inherit;
}
a:hover {
color: #0e69e9;
}
h2 {
color: #7cae49;
text-align: center;
font-size: 30px;
}
.Services {
box-sizing: border-box;
width: 90%;
margin: 5px;
padding: 5px;
vertical-align: top;
text-align: center;
display: inline-block;
color: #7cae49;
}
img {
max-height: 60%;
max-width: 90%;
display: block;
margin-left: auto;
margin-right: auto;
border-radius: 10px;
}
Thanks for looking. Cheers!
Try this.
inside your style.css in #cover, change the top value to 0px;
#cover {
position: absolute;
top: 0px;
width: 100%;
color: white;
text-align: center;
vertical-align: middle;
display: flex, inline-block;
font-size: 20px;
}
I have written some codes in HTML and CSS. The output is shown in the screenshot.
When a menu item is selected ( is expanded), the color section at the right side of the menu disapears while aforementioned menu is selected (after mouse is not hovering the item).
How to make the color stay even after the mouse is not over the menu?
(Please do not suggest any Java Script code.)
CSS Multi-Level Accordion Menu
* {
margin: 0;
padding: 0;
font-family: Arial;
font-size: 14px;
}
.block {
float: right;
max-width: 360px;
width: 100%;
height: 100%;
background-color: white;
overflow: hidden;
margin: 0;
}
.block > div {
display: block;
position: relative;
background-color: #fff;
color: #767676;
border-bottom: 1px solid #e5e5e5;
border-left: 1px solid #e5e5e5;
}
.block > div:nth-child(1):before {
font-family: 'FontAwesome';
content: "\F0CA";
font-size: 16px;
width: 50px;
font-weight: bold;
text-align: center;
position: absolute;
right: 0;
top: 0;
line-height: 50px;
margin: 0;
color: #767676;
border-right: 4px solid #E94B3B;
background: none; /* For browsers that do not support gradients */
background: -webkit-linear-gradient(to right, rgba(0,0,0,0) 50%, #E94B3B 50%); /* Safari 5.1-6.0 */
background: -o-linear-gradient(to right, rgba(0,0,0,0) 50%, #E94B3B 50%); /* For Opera 11.6-12.0 */
background: -moz-linear-gradient(to right, rgba(0,0,0,0) 50%, #E94B3B 50%); /* For Firefox 3.6-15 */
background: linear-gradient(to right, rgba(0,0,0,0) 50%, #E94B3B 50%); /* Standard syntax */
background-size: 200% 100%;
transition: all 0.25s ease-in-out;
}
.block > div:nth-child(1):hover:before {
background-position: 100% 0;
color: white;
}
.block > div:nth-child(2):before {
font-family: 'FontAwesome';
content: "\F0F6";
font-size: 16px;
width: 50px;
font-weight: bold;
text-align: center;
position: absolute;
right: 0;
top: 0;
line-height: 50px;
margin: 0;
color: #767676;
border-right: 4px solid #ffb61c;
background: none; /* For browsers that do not support gradients */
background: -webkit-linear-gradient(to right, rgba(0,0,0,0) 50%, #ffb61c 50%); /* Safari 5.1-6.0 */
background: -o-linear-gradient(to right, rgba(0,0,0,0) 50%, #ffb61c 50%); /* For Opera 11.6-12.0 */
background: -moz-linear-gradient(to right, rgba(0,0,0,0) 50%, #ffb61c 50%); /* For Firefox 3.6-15 */
background: linear-gradient(to right, rgba(0,0,0,0) 50%, #ffb61c 50%); /* Standard syntax */
background-size: 200% 100%;
transition: all 0.25s ease-in-out;
}
.block > div:nth-child(2):hover:before {
background-position: 100% 0;
color: white;
}
.block > div > input + label {
cursor: pointer;
display: block;
line-height: 50px;
background-color: white;
transition: background-color 0.5s;
color: #767676;
padding-right: 60px;
text-align: right;
}
.block > div > input ~ div {
visibility: hidden;
max-height: 0;
padding: 0;
opacity: 0;
transition: all 0.5s;
}
.block > div > input:checked + label {
background-color: #f3f3f3;
transition: background-color 0.5s;
color: black;
}
.block > div > input:checked ~ div {
display: block;
opacity: 1;
visibility: visible;
height: auto;
max-height: 10000px;
padding: 0;
transition: all 0.5s;
}
.block a {
display: block;
line-height: 50px;
text-decoration: none;
color: black;
border-top: solid 1px #e5e5e5;
padding-right: 50px;
text-align: right;
}
.block a:hover {
background: #eeeeee;
}
#font-face {
font-family: 'FontAwesome';
src: url('../fonts/FontAwesome.otf') format('opentype');
}
<div class="block">
<div>
<input type="radio" name="item" id="item-one" hidden />
<label for="item-one">First</label>
<div>
<p>Menu 1.1</p>
<p>Menu 1.2</p>
<p>Menu 1.3</p>
</div>
</div>
<div>
<input type="radio" name="item" id="item-two" hidden />
<label for="item-two">second</label>
<div>
<p>Menu 2.1</p>
<p>Menu 2.2</p>
<p>Menu 2.3</p>
</div>
</div>
</div>
You can refactor your HTML a bit so that the hover state is possible to achieve with :checked on your inputs instead.
First, replace the pseudo element on .block>div with a span element that goes after the label. We need something that's after the input so we can select it with CSS, since there is no CSS parent selector. And we can't use pseudo elements on inputs, so we'll just add a span instead.
<div class="block">
<div>
<input type="checkbox" name="item" id="item-one" hidden />
<label for="item-one">First</label>
<span></span>
<div>
<p>Menu 1.1</p>
<p>Menu 1.2</p>
<p>Menu 1.3</p>
</div>
</div>
</div>
Note that I took the little box symbol out of your content property from the pseudo element and jut put it in the span.
After that, it's just a matter of changing your selectors. So this...
.block > div:nth-child(1):before { ... }
.block > div:nth-child(1):hover:before { ... }
Becomes this...
#item-one + label + span { ... }
.block>div:nth-child(1):hover #item-one + label + span,
#item-one:checked + label + span { ... }
That's it!
You do need to add an explicit height on the span that was not there for the pseudo element, as well as set the span to display: block. The rest of the styles are exactly the same.
Final note is that I changed your inputs from type="radio" to type="checkbox". That way, you can collapse them instead of one being forced to be open all the time once you click one.
Here's a snippet where the first input uses the new style and the second one is the same as your original:
* {
margin: 0;
padding: 0;
font-family: Arial;
font-size: 14px;
}
.block {
float: right;
max-width: 360px;
width: 100%;
height: 100%;
background-color: white;
overflow: hidden;
margin: 0;
}
.block>div {
display: block;
position: relative;
background-color: #fff;
color: #767676;
border-bottom: 1px solid #e5e5e5;
border-left: 1px solid #e5e5e5;
}
#item-one + label + span {
display: block;
font-family: 'FontAwesome';
content: "\F0CA";
font-size: 16px;
width: 50px;
height: 50px;
font-weight: bold;
text-align: center;
position: absolute;
right: 0;
top: 0;
line-height: 50px;
margin: 0;
color: #767676;
border-right: 4px solid #E94B3B;
background: none;
/* For browsers that do not support gradients */
background: -webkit-linear-gradient(to right, rgba(0, 0, 0, 0) 50%, #E94B3B 50%);
/* Safari 5.1-6.0 */
background: -o-linear-gradient(to right, rgba(0, 0, 0, 0) 50%, #E94B3B 50%);
/* For Opera 11.6-12.0 */
background: -moz-linear-gradient(to right, rgba(0, 0, 0, 0) 50%, #E94B3B 50%);
/* For Firefox 3.6-15 */
background: linear-gradient(to right, rgba(0, 0, 0, 0) 50%, #E94B3B 50%);
/* Standard syntax */
background-size: 200% 100%;
transition: all 0.25s ease-in-out;
}
.block>div:nth-child(1):hover #item-one + label + span,
#item-one:checked + label + span {
background-position: 100% 0;
color: white;
}
.block>div:nth-child(2):before {
font-family: 'FontAwesome';
content: "\F0F6";
font-size: 16px;
width: 50px;
font-weight: bold;
text-align: center;
position: absolute;
right: 0;
top: 0;
line-height: 50px;
margin: 0;
color: #767676;
border-right: 4px solid #ffb61c;
background: none;
/* For browsers that do not support gradients */
background: -webkit-linear-gradient(to right, rgba(0, 0, 0, 0) 50%, #ffb61c 50%);
/* Safari 5.1-6.0 */
background: -o-linear-gradient(to right, rgba(0, 0, 0, 0) 50%, #ffb61c 50%);
/* For Opera 11.6-12.0 */
background: -moz-linear-gradient(to right, rgba(0, 0, 0, 0) 50%, #ffb61c 50%);
/* For Firefox 3.6-15 */
background: linear-gradient(to right, rgba(0, 0, 0, 0) 50%, #ffb61c 50%);
/* Standard syntax */
background-size: 200% 100%;
transition: all 0.25s ease-in-out;
}
.block>div:nth-child(2):hover:before {
background-position: 100% 0;
color: white;
}
.block>div>input+label {
cursor: pointer;
display: block;
line-height: 50px;
background-color: white;
transition: background-color 0.5s;
color: #767676;
padding-right: 60px;
text-align: right;
}
.block>div>input~div {
visibility: hidden;
max-height: 0;
padding: 0;
opacity: 0;
transition: all 0.5s;
}
.block>div>input:checked+label {
background-color: #f3f3f3;
transition: background-color 0.5s;
color: black;
}
.block>div>input:checked~div {
display: block;
opacity: 1;
visibility: visible;
height: auto;
max-height: 10000px;
padding: 0;
transition: all 0.5s;
}
.block a {
display: block;
line-height: 50px;
text-decoration: none;
color: black;
border-top: solid 1px #e5e5e5;
padding-right: 50px;
text-align: right;
}
.block a:hover {
background: #eeeeee;
}
#font-face {
font-family: 'FontAwesome';
src: url('../fonts/FontAwesome.otf') format('opentype');
}
<div class="block">
<div>
<input type="checkbox" name="item" id="item-one" hidden />
<label for="item-one">First</label>
<span></span>
<div>
<p>Menu 1.1</p>
<p>Menu 1.2</p>
<p>Menu 1.3</p>
</div>
</div>
<div>
<input type="checkbox" name="item" id="item-two" hidden />
<label for="item-two">second</label>
<div>
<p>Menu 2.1</p>
<p>Menu 2.2</p>
<p>Menu 2.3</p>
</div>
</div>
</div>
$('.t-blog-list-sidebar').find('li').click(function(e){
$('.t-blog-list-sidebar').find('li').removeClass('active');
// console.log(this, e);
$(this).addClass('active');
e.stopPropagation();
})
$("li.no-a").click(function(e){
$(this).toggleClass('rev');
$(this).children("ul").collapse('toggle');
e.stopPropagation();
} );
#import "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css";
#import "https://use.fontawesome.com/releases/v5.2.0/css/all.css";
.bg-grey{
background:#f5f5f5;
}.t-blog-list-sidebar ul:nth-child(2) li.no-a {
border: 1px solid #333;
}
section#t-page-title .t-sub-header {
margin-bottom: 30px;
}
#t-page-title .t-sub-header h2 {
font-weight: 400;
text-transform: uppercase;
}
.h-tab{
margin-top: 130px;
}
.h-tab .container span {
display: inline-block;
cursor: pointer;
padding: 28px 40px;
}
.h-tab .container a span h3 {
font-size: 27px;
text-transform: uppercase;
color: #fff;
}
.h-tab .container a span.active h3 {
font-weight: 500;
}
#t-page-title {
position: relative;
padding: 15px 0;
background-color: #F5F5F5;
border-bottom: 1px solid #EEE;
}
#t-page-title .breadcrumb {
position: absolute !important;
width: auto !important;
left: 15px !important;
margin: -5px 0 0 0 !important;
background-color: transparent !important;
padding: 0 !important;
font-size: 12px;
}
.h-tab .container span.active {
border-bottom: 7px solid #e87327;
box-shadow: 0px 0px 20px -2px #ffffff;
}
ul.t-ul-r {
float: right;
}
.t-recent-post {
width: 100%;
list-style-type: none;
}
.widget-sidebar li.t-recent-post .t-sub-header h3 i {
font-size: 32px;
padding-right: 5px;
}
.widget-sidebar li.t-recent-post .t-sub-header h3{
text-transform: uppercase;
}
.t-subbody ul.t-ul li:not(.no-a):hover {
cursor: pointer;
background: #e0e0e0;
}
.t-subbody ul.t-ul li {
line-height: 11px;
float: none;
padding-left: 21px;
padding: 4px;
color: #676666;
position: relative;
cursor: pointer;
}
.t-subbody .t-ul li:before {
content: "\f061";
font-family: 'Font Awesome 5 Free';
font-weight: 900;
font-style: normal;
padding-right: 2px;
font-size: 10px;
}
li> ul.t-ul {
padding-top: 13px;
transition: .5s;
}
#t-page-title {
margin-bottom: 16px;
}
.t-subbody .t-ul li.active:not(.no-a):after {
content: "\00a0";
width: 35px;
height: 35px;
background: #f5f5f5;
position: absolute;
transform: rotate(46deg);
right: -33px;
margin-top: -10px;
}
.t-subbody .t-ul li> ul li.active:not(.no-a):after {
right: -45px;
}
.t-subbody .t-ul li> ul li ul > li.active:not(.no-a):after {
right: -50px;
}
.t-subbody .t-ul li> ul li ul > li.active:not(.no-a):after {
right: -55px;
}
.t-subbody .t-ul li> ul li > ul li > ul li.active:not(.no-a):after {
right: -65px;
}
.t-subbody ul.t-ul li.no-a:after {
content: "\f107";
font-family: 'Font Awesome 5 Free';
font-weight: 900;
padding-right: 2px;
font-size: 18px;
position: absolute;
top:0;
font-style: normal;
right: 17px;
transition: .2s;
}
.t-subbody ul.t-ul li.no-a.rev:after {
transition: .2s;
transform: rotate(180deg);
}
.t-entry .entry-c {
background: #fff;
box-shadow: 0 3px 1px -2px rgba(0,0,0,.2), 0 2px 2px 0 rgba(0,0,0,.14), 0 1px 5px 0 rgba(0,0,0,.12);
position: relative;
padding: 24px;
border-radius: 2px;
margin: 20px 0;
}
li.t-recent-post p small {
display: block;
margin-top: 10px;
padding-bottom: 11px;
border-bottom: 1px solid #b9b9b9;
}
.t-blog-list-sidebar ul{
list-style:none;
padding-left:0px;
}
/* blog css end */
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<section class="section">
<div class="container ">
<div class="col-md-3 col-sm-3">
<div class="widget-sidebar">
<h2 class="title-widget-sidebar">TUTORIAL</h2>
<div class="t-blog-list-sidebar">
<ul>
<li class="t-recent-post">
<div class="t-sub-header">
<h3><i class="fab fa-java"></i> java</h3>
</div>
<div class="t-subbody">
<ul class="entry-meta clearfix t-ul">
<li class='active'> menu-1 </li>
<li> menu-2 </li>
<li class="no-a"> menu-3 start
<ul class="t-ul collapse">
<li>menu-3.1 </li>
<li class="no-a"> menu-3.2
<ul class="t-ul collapse">
<li class="no-a"> menu-3.2.1
<ul class="t-ul collapse">
<li> menu-3.2.1.1 </li>
<li> menu-3.2.1.2 </li>
</ul>
</li>
<li> menu-3.2.2 </li>
</ul>
</li>
<li> menu-3.3 </li>
</ul>
</li>
</ul>
</div>
<p><small><i class="fa fa-calendar" data-original-title="" title=""></i>15 November 2014</small> </p>
</li>
</ul>
<ul>
<li class="t-recent-post">
<div class="t-sub-header">
<h3><i class="fab fa-java"></i> java</h3>
</div>
<div class="t-subbody">
<ul class="entry-meta clearfix t-ul">
<li class='active'> menu-1 </li>
<li> menu-2 </li>
<li class="no-a"> menu-3 start
<ul class="t-ul collapse">
<li>menu-3.1 </li>
<li class="no-a"> menu-3.2
<ul class="t-ul collapse">
<li class="no-a"> menu-3.2.1
<ul class="t-ul collapse">
<li> menu-3.2.1.1 </li>
<li> menu-3.2.1.2 </li>
</ul>
</li>
<li> menu-3.2.2 </li>
</ul>
</li>
<li> menu-3.3 </li>
</ul>
</li>
</ul>
</div>
<p><small><i class="fa fa-calendar" data-original-title="" title=""></i>15 November 2014</small> </p>
</li>
</ul>
</div>
</div>
</div>
<div class="col-md-9 col-sm-9 small-thumbs bg-grey">
<section id="t-page-title">
<div class="t-sub-header">
<h2><i class="fab fa-java"></i> java</h2>
</div>
<div class="container clearfix">
<div class="row">
<div class="col-md-12 col-xs-12 col-sm-12">
<ol class="breadcrumb">
<li>Tutorial </li>
<li class="active">java</li>
</ol>
</div>
</div>
</div>
</section>
<div class="clearfix t-entry">
<!-- card start -->
<div class="entry-c">
<div class="entry-title">
<h2>Android market in India</h2>
</div>
<div class="entry-content">
<p> </p>
<p class="MsoNormal"><span lang="EN-IN">India, as all know, is a land of diversity. A home to myriad cultures, this land has been binding them together,since decades. Year by year, time to time, as the country lurked somewhere on the map on technological growth, now is the time when it has emerged from hibernation. India today is a ripe market for all technological predators. From television to mobile phone; from laptops to phablets; Indians now have climbed the technological ladder, each time a rung higher.</span> </p>
<p></p>
</div>
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12">
<ul class="entry-meta clearfix t-ul">
<li><i class="icon-thumbs-up"></i> 12 </li>
<li><i class="icon-comments"></i> 24 </li>
</ul>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
<ul class="entry-meta clearfix t-ul-r">
<li><i class="icon-calendar3"></i> 3:05 pm on Saturday 15 November 2014 </li>
</ul>
</div>
</div>
</div>
<div class="entry-c">
<div class="entry-title">
<h2>Android market in India</h2>
</div>
<div class="entry-content">
<p> </p>
<p class="MsoNormal"><span lang="EN-IN">India, as all know, is a land of diversity. A home to myriad cultures, this land has been binding them together,since decades. Year by year, time to time, as the country lurked somewhere on the map on technological growth, now is the time when it has emerged from hibernation. India today is a ripe market for all technological predators. From television to mobile phone; from laptops to phablets; Indians now have climbed the technological ladder, each time a rung higher.</span> </p>
<p></p>
</div>
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12">
<ul class="entry-meta clearfix t-ul">
<li><i class="icon-thumbs-up"></i> 12 </li>
<li><i class="icon-comments"></i> 24 </li>
</ul>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
<ul class="entry-meta clearfix t-ul-r">
<li><i class="icon-calendar3"></i> 3:05 pm on Saturday 15 November 2014 </li>
</ul>
</div>
</div>
</div>
<div class="entry-c">
<div class="entry-title">
<h2>Android market in India</h2>
</div>
<div class="entry-content">
<p> </p>
<p class="MsoNormal"><span lang="EN-IN">India, as all know, is a land of diversity. A home to myriad cultures, this land has been binding them together,since decades. Year by year, time to time, as the country lurked somewhere on the map on technological growth, now is the time when it has emerged from hibernation. India today is a ripe market for all technological predators. From television to mobile phone; from laptops to phablets; Indians now have climbed the technological ladder, each time a rung higher.</span> </p>
<p></p>
</div>
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12">
<ul class="entry-meta clearfix t-ul">
<li><i class="icon-thumbs-up"></i> 12 </li>
<li><i class="icon-comments"></i> 24 </li>
</ul>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
<ul class="entry-meta clearfix t-ul-r">
<li><i class="icon-calendar3"></i> 3:05 pm on Saturday 15 November 2014 </li>
</ul>
</div>
</div>
</div>
<div class="entry-c">
<div class="entry-title">
<h2>Android market in India</h2>
</div>
<div class="entry-content">
<p> </p>
<p class="MsoNormal"><span lang="EN-IN">India, as all know, is a land of diversity. A home to myriad cultures, this land has been binding them together,since decades. Year by year, time to time, as the country lurked somewhere on the map on technological growth, now is the time when it has emerged from hibernation. India today is a ripe market for all technological predators. From television to mobile phone; from laptops to phablets; Indians now have climbed the technological ladder, each time a rung higher.</span> </p>
<p></p>
</div>
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12">
<ul class="entry-meta clearfix t-ul">
<li><i class="icon-thumbs-up"></i> 12 </li>
<li><i class="icon-comments"></i> 24 </li>
</ul>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
<ul class="entry-meta clearfix t-ul-r">
<li><i class="icon-calendar3"></i> 3:05 pm on Saturday 15 November 2014 </li>
</ul>
</div>
</div>
</div>
<!-- card start end-->
</div>
</div>
</div>
</section>
So, I'm using a while loop with PHP. The while loop makes the following code:
<img src='$user_six' class='avatar_friend'>
Please don't worry about $user_six or the background info on the while loop. I know it works. I'm trying to put three avatars on top of a movie. The problem is that each image takes space and is ruining the spacing with the movies.
This is the information of .avatar_friend:
.avatar_friend {
width: 36px;
height: 36px;
position: relative;
z-index: 10;
border: 1px solid white;
}
I think absolute positioning works better, but the images overlap each other.
This is the information of .avatar_friend:
.avatar_friend {
width: 36px;
height: 36px;
position: absolute;
z-index: 10;
border: 1px solid white;
}
How can I have the best of both positions? I want proper spacing, but no overlapping. How can I achieve this effect?
EDIT:
I've tried doing the following:
html
<div id='container'> <img src='$user_six' class='avatar_friend'> </div>
css
#container {
position: absolute;
}
.avatar_friend {
width: 36px;
height: 36px;
position: relative;
z-index: 10;
border: 1px solid white;
}
This did not work...
EDIT 2:
html
<!DOCTYPE html>
<html>
<head>
<title> Movies </title>
<link rel="stylesheet" href="http://fontawesome.io/assets/font-awesome/css/font-awesome.css">
<link rel='stylesheet' href='main.css'>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src='main.js'></script>
</head>
<body>
<!-- Navigation -->
<div id='nav'>
<!-- Profile Wrapper -->
<ul class="profile-wrapper">
<li>
<!-- user profile -->
<div class="profile">
<img src="avatars/default.png" />
MatthewMalan <i class="fa fa-caret-down" id="caret-down"></i>
<!-- more menu -->
<ul class="menu">
<li>Sign Out</li>
<li>Sign Out</li>
<li>Sign Out</li>
</ul>
</div>
</li>
</ul>
<!-- End of Profile Wrapper -->
</div>
<!-- End of Navigation -->
<!-- Movie Content -->
<div id='movie_content2'>
<div id='movie_line'>
<div id='movie_line2'></div>
<!-- Dropdown Selection -->
<nav>
<ul id="dropdown_selection">
<li>Most Recent
<ul>
<li> Most Liked </li>
<li> My History </li>
<li> My Likes </li>
</ul>
</li>
</ul>
</nav>
<!-- End of Dropdown Selection -->
<div id='descriptive_div' number='1'> <i class='fa fa-caret-left' id='descriptive_caret' number='1'></i> <a href='like.php?number=7&page=1'><a href='like.php?number=7&page=1&code=1&sorting=recent'> <div class='like_button' number='1'> Like </div> </a></a> <span id='descriptive_div_text'> Professional, Clean, Ready to Go </span> <div id='files_left'> 3 Copies Left </div> </div><a href='open.php?destination=movies/56c7ede7d3ed3658.44679765.mp4'> <div class='movie_length' number='1'> <div id='movie_length_text' number='1'> 1h 20m </div> </div> </a><a href='open.php?destination=movies/56c7ede7d3ed3658.44679765.mp4'> <div class='movie_rating3' number='1'> <span id='movie_rating_text' number='1'> G </span> </div> </a><a href='open.php?destination=movies/56c7ede7d3ed3658.44679765.mp4'> <img src='covers/inside.jpg' class='movie_size' number='1'> </a><div id='descriptive_div' number='2'> <i class='fa fa-caret-left' id='descriptive_caret' number='2'></i> <a href='like.php?number=8&page=1'><a href='like.php?number=8&page=1&code=1&sorting=recent'> <div class='like_button' number='2'> Like </div> </a></a> <span id='descriptive_div_text'> s </span> <div id='files_left'> 1 Copy Left </div> </div><a href='open.php?destination=movies/56c7ede7d3ed3108.44679765.mp4'> <div class='movie_length' number='2'> <div id='movie_length_text' number='2'> 2h 16m </div> </div> </a><a href='open.php?destination=movies/56c7ede7d3ed3108.44679765.mp4'> <div class='movie_rating' number='2'> <span id='movie_rating_text' number='2'> PG-13 </span> </div> </a><a href='open.php?destination=movies/56c7ede7d3ed3108.44679765.mp4'> <img src='covers/star wars.jpg' class='movie_size' number='2'> </a><img src='avatars/sam.jpg' class='avatar_friend'><img src='avatars/traek.jpg' class='avatar_friend'><img src='avatars/jessie.jpg' class='avatar_friend'><div id='descriptive_div' number='3'> <i class='fa fa-caret-left' id='descriptive_caret' number='3'></i> <a href='like.php?number=9&page=1'><a href='like.php?number=9&page=1&sorting=recent'> <div class='liked_button' number='3'> Like </div> </a></a> <span id='descriptive_div_text'> r </span> <div id='files_left'> 7 Copies Left </div> </div><a href='open.php?destination=movies/56e06853166618.33290858.mp4'> <div class='movie_length' number='3'> <div id='movie_length_text' number='3'> r </div> </div> </a><a href='open.php?destination=movies/56e06853166618.33290858.mp4'> <div class='movie_rating4' number='3'> <span id='movie_rating_text' number='3'> PG-13 </span> </div> </a><a href='open.php?destination=movies/56e06853166618.33290858.mp4'> <img src='covers/56e068530dc9f9.52895782.jpg' class='movie_size3' number='3'> </a><br><div class="complete_page">1</div> </div>
</div>
<!-- End of Movie Content -->
</body>
</html>
css
/* Rating of Movie Content */
.movie_rating, .movie_rating2, .movie_rating3, .movie_rating4, .movie_rating5, .movie_rating6, .movie_length, .movie_length2 {
display: inline-block;
width: 100px;
height: 30px;
background: #E10E0D;
color: white;
text-align: center;
position: absolute;
z-index: 5;
font-family: 'Days One', sans-serif;
cursor: pointer;
margin-top: -10px;
margin-left: 16px;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
border: 1px solid #FE4042;
}
.movie_rating4, .movie_rating5, .movie_rating6 {
background: #7D5505;
border: 1px solid #F9BA01;
}
.movie_length, .movie_length2 {
width: 120px;
background: #02477D;
border: 1px solid #97D0F2;
margin-top: 239px;
}
.movie_length2 {
width: 75px;
}
.movie_rating2, .movie_rating5 {
width: 60px;
}
.movie_rating3, .movie_rating6 {
width: 40px;
}
#movie_rating_text, #movie_length_text {
font-size: 25px;
position: relative;
top: 0px;
font-family: 'Days One', sans-serif;
letter-spacing: 1px;
}
/* Description of Movie */
#descriptive_div {
position: absolute;
width: 400px;
min-height: 241px;
background: black;
color: white;
z-index: 6;
margin-left: 228px;
margin-top: -10px;
font-size: 16px;
line-height: 25px;
padding-bottom: 30px;
border: 5px solid #ccc;
display: none;
}
#descriptive_div_text {
width: 370px;
display: inline-block;
position: relative;
left: 14px;
top: 14px;
text-align: left;
}
#descriptive_caret {
color: #ccc;
font-size: 51px;
position: absolute;
margin-left: -19px;
margin-top: 115px;
display: none;
}
/* End of Description of Movie */
/* Movie Line */
#movie_line2 {
width: 1px;
height: 635px;
background: #ccc;
position: absolute;
left: 1120px;
top: 10px;
z-index: 2;
}
/* End of Movie Line */
/* End of Rating of Movie Content */
/* Like Button */
.like_button, .liked_button {
background: #0566AE;
width: 50px;
padding: 3px;
color: white;
text-align: center;
position: absolute;
margin-left: -95px;
z-index: 6;
border-radius: 3px;
cursor: pointer;
font-family: 'Days One', sans-serif;
font-size: 18px;
letter-spacing: 1px;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.liked_button {
background: #2C599D;
margin-left: -95px;
margin-top: 0;
}
.like_button:hover {
background: #2C599D;
}
.show {
opacity: 1;
}
/* End of Like Button */
/* End of Movie Content */
/* Tab System for admin.php */
h1, h2, h3, h4 {
padding: 0;
margin: .1rem 0;
border-left: 4px solid #4F2CCA;
padding-left: 8px;
}
.material-tabs {
display: block;
float: left;
padding: 16px;
padding-top: 0;
width: 100%;
max-width: 480px;
left: calc(50% - 480px/2);
position: relative;
margin: 96px auto;
background: #fff;
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23) !important;
border-radius: 2px;
}
#media all and (max-width: 480px) {
.material-tabs {
max-width: 100%;
left: 0;
}
}
.visible {
position: relative;
opacity: 1;
width: 100%;
height: auto;
float: left;
-webkit-transition: opacity .35s ease;
transition: opacity .35s ease;
z-index: 3;
}
.hidden {
position: absolute;
opacity: 0;
z-index: 0;
-webkit-transition: opacity 0s ease;
transition: opacity 0s ease;
}
.hidden img {
display: none;
}
[class*="tabbed-section-"] {
float: left;
color: #000;
}
[class*="tabbed-section-"] img {
display: block;
width: 80%;
margin: auto 10%;
}
.tabbed-section__selector {
position: relative;
height: 32px;
top: -31.2px;
left: -16px;
padding: 0;
margin: 0;
width: 100%;
float: left;
}
.tabbed-section__selector [class*="-tab-"] {
float: left;
display: block;
height: 32px;
line-height: 32px;
width: 100px;
text-align: center;
background: #fff;
font-weight: bold;
text-decoration: none;
color: black;
font-size: 14px;
}
.tabbed-section__selector [class*="-tab-"].active {
color: #4F2CCA;
}
.tabbed-section__selector a:first-child {
border-top-left-radius: 2px;
}
.tabbed-section__selector a:last-of-type {
border-top-right-radius: 2px;
}
.tabbed-section__highlighter {
position: absolute;
z-index: 10;
bottom: 0;
height: 2px;
background: #4F2CCA;
max-width: 100px;
width: 100%;
-webkit-transform: translateX(0);
transform: translateX(0);
display: block;
left: 0;
-webkit-transition: -webkit-transform 0.23s ease;
transition: -webkit-transform 0.23s ease;
transition: transform 0.23s ease;
transition: transform 0.23s ease, -webkit-transform 0.23s ease;
}
.tabbed-section__selector-tab-3.active ~ .tabbed-section__highlighter {
-webkit-transform: translateX(200px);
transform: translateX(200px);
}
.tabbed-section__selector-tab-2.active ~ .tabbed-section__highlighter {
-webkit-transform: translateX(100px);
transform: translateX(100px);
}
.tabbed-section__selector-tab-1.active ~ .tabbed-section__highlighter {
-webkit-transform: translateX(0);
transform: translateX(0);
}
.divider {
background: rgba(0, 0, 0, 0.1);
position: relative;
display: block;
float: left;
width: 100%;
height: 1px;
margin: 8px 0;
padding: 0;
overflow: hidden;
}
/* End of Tab system for admin.php */
/* Create */
#title, #length {
font-size: 16px;
border: 1px solid #ccc;
padding: 11px;
outline: none;
border-radius: 3px;
width: 400px;
}
#title:focus, #description:focus, #length:focus {
border: 1px solid #A9A9A9;
}
#description {
font-size: 16px;
border: 1px solid #ccc;
padding: 11px;
outline: none;
border-radius: 3px;
width: 400px;
resize: vertical;
max-height: 70px;
}
#rating_text {
position: relative;
top: -10px;
}
#length_text {
position: relative;
top: -10px;
}
/* End of Create */
/* Dropdown Selection */
nav {
margin: 10rem auto;
width: 220px;
position: absolute;
left: 1150px;
top: -140px;
}
nav ul {
color: #fff;
font-family: sans-serif;
font-size: 1.4rem;
letter-spacing: .1rem;
position: relative;
width: 100%;
}
nav a {
background: #1A1A1A;
color: inherit;
display: block;
text-decoration: none;
padding: 1rem;
}
nav ul ul a:hover {
background: #666;
}
nav ul ul {
display: none;
padding-top: 1rem;
position: absolute;
}
nav ul:hover ul {
display: block;
}
nav ul:first-child:hover > li:first-child:before {
border: .7rem solid transparent;
border-top-color: #fff;
}
nav ul ul > li:not(:last-child) {
border-bottom: 1px solid white;
}
nav ul > li:first-child:before {
content: "";
position: absolute;
}
nav ul:first-child > li:first-child:before {
border: .7rem solid transparent;
border-top-color: #fff;
pointer-events: none;
left: 175px;
top: 30px;
}
.fa {
margin-right: .5rem;
}
/* End of Dropdown Selection */
/* Files Left */
#files_left {
color: red;
width: 110px;
padding: 1px;
border: 1px solid red;
text-align: center;
border-radius: 10%;
position: relative;
left: 15px;
top: 20px;
}
/* End of Files Left */
/* Avatar */
.avatar_friend {
width: 36px;
height: 36px;
position: relative;
z-index: 10;
border: 1px solid white;
}
/* End of Avatar */
Some of the CSS may be for other pages. I realize this is a lot of information. Let me know if you need anything else...
First of all, you use the same id in 6 elements for every movie, which you shouldn't. An id is unique, so change that to like 'descriptive_div_1', 'descriptive_caret_1', etc (I did that in the samples below so you can see where).
This is how a movie section looks like (repeated for each movie, no wrapper around each of them)
<div id='descriptive_div_2' number='2'>
<i class='fa fa-caret-left' id='descriptive_caret_2' number='2'></i>
<a href='like.php?number=8&page=1'>
<a href='like.php?number=8&page=1&code=1&sorting=recent'>
<div class='like_button' number='2'> Like </div>
</a>
</a>
<span id='descriptive_div_text_2'> s </span>
<div id='files_left_2'> 1 Copy Left </div>
</div>
<a href='open.php?destination=movies/56c7ede7d3ed3108.44679765.mp4'>
<div class='movie_length' number='2'>
<div id='movie_length_text_2' number='2'> 2h 16m </div>
</div>
</a>
<a href='open.php?destination=movies/56c7ede7d3ed3108.44679765.mp4'>
<div class='movie_rating_2' number='2'>
<span id='movie_rating_text_2' number='2'> PG-13 </span>
</div>
</a>
<a href='open.php?destination=movies/56c7ede7d3ed3108.44679765.mp4'>
<img src='covers/star wars.jpg' class='movie_size' number='2'>
</a>
<img src='avatars/sam.jpg' class='avatar_friend'>
<img src='avatars/traek.jpg' class='avatar_friend'>
<img src='avatars/jessie.jpg' class='avatar_friend'>
So to be able to target each avatar_friend in each movie section, you need CSS rules like this
.avatar_friend {
width: 36px;
height: 36px;
position: absolute;
z-index: 10;
border: 1px solid white;
}
div[number] + a + a + a ~ .avatar_friend:nth-of-type(3n+1) {
left: 0px;
}
div[number] + a + a + a ~ .avatar_friend:nth-of-type(3n+2) {
left: 36px;
}
div[number] + a + a + a ~ .avatar_friend:nth-of-type(3n+3) {
left: 72px;
}
The problem with this is you need to know how many avatars_friend's it is, as you need to change the nth-of-type counter and the amount of CSS rules accordingly.
By adding a wrapper like this for the avatar's, will fix it for you
<div id='descriptive_div_2' number='2'>
<i class='fa fa-caret-left' id='descriptive_caret_2' number='2'></i>
<a href='like.php?number=8&page=1'>
<a href='like.php?number=8&page=1&code=1&sorting=recent'>
<div class='like_button' number='2'> Like </div>
</a>
</a>
<span id='descriptive_div_text_2'> s </span>
<div id='files_left_2'> 1 Copy Left </div>
</div>
<a href='open.php?destination=movies/56c7ede7d3ed3108.44679765.mp4'>
<div class='movie_length' number='2'>
<div id='movie_length_text_2' number='2'> 2h 16m </div>
</div>
</a>
<a href='open.php?destination=movies/56c7ede7d3ed3108.44679765.mp4'>
<div class='movie_rating_2' number='2'>
<span id='movie_rating_text_2' number='2'> PG-13 </span>
</div>
</a>
<a href='open.php?destination=movies/56c7ede7d3ed3108.44679765.mp4'>
<img src='covers/star wars.jpg' class='movie_size' number='2'>
</a>
<div class='avatar_friend_wrapper'>
<img src='avatars/sam.jpg' class='avatar_friend'>
<img src='avatars/traek.jpg' class='avatar_friend'>
<img src='avatars/jessie.jpg' class='avatar_friend'>
</div>
.avatar_friend_wrapper {
position: absolute;
left: 0;
}
.avatar_friend {
width: 36px;
height: 36px;
position: relative;
z-index: 10;
border: 1px solid white;
}
What I recommend to do, would be to change your PHP loops so they generate something like this instead, where each movie item has its own wrapper.
With that you get a completely different control how to layout each movie info item based on screen size etc.
<div class='movie_div_2' number='2'>
<div id='descriptive_div_2' number='2'>
<i class='fa fa-caret-left' id='descriptive_caret_2' number='2'></i>
<a href='like.php?number=8&page=1'>
<a href='like.php?number=8&page=1&code=1&sorting=recent'>
<div class='like_button' number='2'> Like </div>
</a>
</a>
<span id='descriptive_div_text_2'> s </span>
<div id='files_left_2'> 1 Copy Left </div>
</div>
<a href='open.php?destination=movies/56c7ede7d3ed3108.44679765.mp4'>
<div class='movie_length' number='2'>
<div id='movie_length_text_2' number='2'> 2h 16m </div>
</div>
</a>
<a href='open.php?destination=movies/56c7ede7d3ed3108.44679765.mp4'>
<div class='movie_rating_2' number='2'>
<span id='movie_rating_text_2' number='2'> PG-13 </span>
</div>
</a>
<a href='open.php?destination=movies/56c7ede7d3ed3108.44679765.mp4'>
<img src='covers/star wars.jpg' class='movie_size' number='2'>
</a>
<div class='avatar_friend_wrapper'>
<img src='avatars/sam.jpg' class='avatar_friend'>
<img src='avatars/traek.jpg' class='avatar_friend'>
<img src='avatars/jessie.jpg' class='avatar_friend'>
</div>
</div>