I have 4 images and want them to be displayed 2 on each row. Each of them has a width:50% and also a float:left.
HTML
<section class="opportunity">
<div class="main">
<img src="phone.jpg" >
<div class="paragraph">This wil be centered</div>
<div class="content">
<button>Nokia 7210 Classic</button>
</div>
</div>
<div class="main">
<img src="phone.jpg">
<div class="content">
<button>Nokia 7210 Classic</button>
</div>
</div>
<div class="main">
<img src="phone.jpg">
<div class="content">
<button>Nokia 7210 Classic</button>
</div>
</div>
<div class="main">
<img src="phone.jpg">
<div class="content">
<button>Nokia 7210 Classic</button>
</div>
</div>
<div class="clearfix"></div>
</section>
CSS:
.clearfix{
clear: both;
}
section{
text-align: center;
}
.main{
float:left;
width:50%;
text-align: center;
border:10px solid white;
width:306px;
height:306px;
margin : 50px auto;
box-shadow: 0px 0px 25px black;
overflow: hidden;
}
.paragraph{
-webkit-transform: translateY(-300%);
border: 5px solid grey;
background-color: grey;
opacity: 0.5;
}
.main:hover .content,
.main:active .content{
-webkit-transform: translateY(-340px);
-webkit-transition: -webkit-transform 700ms;
}
.content{
width: 306px;
height: 306px;
background: rgba(51, 102, 255, 0.5);
}
img{
height:inherit;
width:inherit;
-webkit-transition: -webkit-transform 5000ms;
}
button{
width: 100%;
height: 50px;
margin-top: 100px;
background: black;
border: 0;
cursor: pointer;
color: white;
font: 16px tahoma;
}
button:hover
{
opacity: 0.5;
}
The problem is that all of the image are displayed within the same row. The width:50% does not seem to applied. How can I display the images two by two instead of having them all displayed on the same line?
You added width twice, with percentage and pixels, you should remove that:
.clearfix{
clear: both;
}
section{
text-align: center;
}
.some-container {
float:left;
width:50%;
position: relative;
}
.main{
text-align: center;
border:10px solid white;
width:306px;
height:306px;
margin : 50px auto;
box-shadow: 0px 0px 25px black;
overflow: hidden;
}
.paragraph{
-webkit-transform: translateY(-300%);
border: 5px solid grey;
background-color: grey;
opacity: 0.5;
}
.main:hover .content,
.main:active .content{
-webkit-transform: translateY(-340px);
-webkit-transition: -webkit-transform 700ms;
}
.content{
width: 306px;
height: 306px;
background: rgba(51, 102, 255, 0.5);
}
img{
height:inherit;
width:inherit;
-webkit-transition: -webkit-transform 5000ms;
}
button{
width: 100%;
height: 50px;
margin-top: 100px;
background: black;
border: 0;
cursor: pointer;
color: white;
font: 16px tahoma;
}
button:hover
{
opacity: 0.5;
}
<section class="opportunity">
<div class="some-container">
<div class="main">
<img src="phone.jpg" >
<div class="paragraph">This wil be centered</div>
<div class="content">
<button>Nokia 7210 Classic</button>
</div>
</div>
</div>
<div class="some-container">
<div class="main">
<img src="phone.jpg">
<div class="content">
<button>Nokia 7210 Classic</button>
</div>
</div>
</div>
<div class="some-container">
<div class="main">
<img src="phone.jpg">
<div class="content">
<button>Nokia 7210 Classic</button>
</div>
</div>
</div>
<div class="some-container">
<div class="main">
<img src="phone.jpg">
<div class="content">
<button>Nokia 7210 Classic</button>
</div>
</div>
</div>
<div class="clearfix"></div>
</section>
The float cannot work because the elements dont fit into a row. You have set a margin. The complete width of an element is width+margin-left+margin-right. That must be smaller than 50%
Instead of using float everywhere, try using a HTML table, with 2 rows and 2 columns.
<table>
<tr>
<td>img1</td>
<td>img2</td>
</tr>
... etc
</table>
Then set all your table cells to be 50% wide using CSS.
You are using float as well as margin:0 auto replace the main css with the following;
.main{
float:left;
width:50%;
text-align: center;
border:10px solid white;
width:306px;
height:306px;
box-shadow: 0px 0px 25px black;
overflow: hidden;
}
You have added the width twice remove that 306px and give box sizing border-box to make sure that borders are taking from inside see this fiddle https://jsfiddle.net/pwfucx16/
<section class="opportunity">
<div class="main">
<img src="phone.jpg" >
<div class="paragraph">This wil be centered</div>
<div class="content">
<button>Nokia 7210 Classic</button>
</div>
</div>
<div class="main">
<img src="phone.jpg">
<div class="content">
<button>Nokia 7210 Classic</button>
</div>
</div>
<div class="main">
<img src="phone.jpg">
<div class="content">
<button>Nokia 7210 Classic</button>
</div>
</div>
<div class="main">
<img src="phone.jpg">
<div class="content">
<button>Nokia 7210 Classic</button>
</div>
</div>
<div class="clearfix"></div>
</section>
Style sheet is
.clearfix{
clear: both;
}
section{
text-align: center;
}
.main{
float:left;
text-align: center;
border:10px solid white;
height:306px;
width:50%;
margin : 50px auto;
box-shadow: 0px 0px 25px black;
overflow: hidden;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.paragraph{
-webkit-transform: translateY(-300%);
border: 5px solid grey;
background-color: grey;
opacity: 0.5;
}
.main:hover .content,
.main:active .content{
-webkit-transform: translateY(-340px);
-webkit-transition: -webkit-transform 700ms;
}
.content{
width: 306px;
height: 306px;
background: rgba(51, 102, 255, 0.5);
}
img{
height:inherit;
width:inherit;
-webkit-transition: -webkit-transform 5000ms;
}
button{
width: 100%;
height: 50px;
margin-top: 100px;
background: black;
border: 0;
cursor: pointer;
color: white;
font: 16px tahoma;
}
button:hover
{
opacity: 0.5;
}
Your main problem is the fact that you have two width properties on the CSS rule for .main. You're setting the width to 50% but then overriding it again a few lines later to a value of 306px:
.main{
float:left;
width:50%;
// ...
width:306px;
// ...
}
Secondly, the 10px border that you're applying to your .main element will not be taken into account when the 50% width is calculated and so your elements will be 20px (2 x 10px) wider than 50%. To fix this, you'll need to set the box-sizing property value to `border-box':
.main {
// ...
-moz-box-sizing: border-box;
box-sizing: border-box;
}
There are a few other kinks to sort out as well but this will solve your requested issue. I'm not sure exactly what you're going for here so when you run into more issues feel free to create another question and link to it here.
Here's a snippet with my proposed fixes to display 2 images in a row:
.clearfix{
clear: both;
}
section{
text-align: center;
}
.main{
float:left;
width:50%;
text-align: center;
border:10px solid white;
height:306px;
margin : 50px auto;
box-shadow: 0px 0px 25px black;
overflow: hidden;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.paragraph{
-webkit-transform: translateY(-300%);
border: 5px solid grey;
background-color: grey;
opacity: 0.5;
}
.main:hover .content,
.main:active .content{
-webkit-transform: translateY(-340px);
-webkit-transition: -webkit-transform 700ms;
}
.content{
width: 100%;
height: 306px;
background: rgba(51, 102, 255, 0.5);
}
img{
height: inherit;
width: inherit;
-webkit-transition: -webkit-transform 5000ms;
}
button{
width: 100%;
height: 50px;
margin-top: 100px;
background: black;
border: 0;
cursor: pointer;
color: white;
font: 16px tahoma;
}
button:hover
{
opacity: 0.5;
}
<section class="opportunity">
<div class="main">
<img src="http://placehold.it/650x350" >
<div class="paragraph">This wil be centered</div>
<div class="content">
<button>Nokia 7210 Classic</button>
</div>
</div>
<div class="main">
<img src="http://placehold.it/650x350">
<div class="content">
<button>Nokia 7210 Classic</button>
</div>
</div>
<div class="main">
<img src="http://placehold.it/650x350">
<div class="content">
<button>Nokia 7210 Classic</button>
</div>
</div>
<div class="main">
<img src="http://placehold.it/650x350">
<div class="content">
<button>Nokia 7210 Classic</button>
</div>
</div>
<div class="clearfix"></div>
</section>
Related
I am trying to code a very simple HTML CSS file and here is my problem.
Here is my code
[https:// codepen.io/anhbui2904/pen/jOxeQgw][1]
My problem is, as you can see in this picture
Because of this code
.service-section .service-item{
flex: 0 0 33.33%;
max-width: 33.33%;
padding: 15px;
}
The pictures become 3 pictures per 1 line. As you can see in this picture
But I use this code
.work-section .work-item {
flex: 0 0 33.33%;
max-width: 33.33%;
padding: 15px;
}
As you can see, seems this code does not work ? The photos are still in line ? I do not know why ? Could you please give me some advice for this problem ? Thank you very much for your time.
#import url('https://fonts.googleapis.com/css?family=Raleway:300,400,700&display=swap');
body{
margin: 0;
line-height: 1.5;
background-color: #f3f2f1;
}
body,
input,textarea,
button{
font-family: 'Raleway', 'sans-serif';
font-weight: 400;
}
*{
box-sizing: border-box;
margin: 0;
}
.container{
max-width: 1170px;
margin: auto;
}
.row{
display: flex;
flex-wrap: wrap;
}
.align-items-center{
align-items: center;
}
.justify-content-between{
justify-content: space-between;
}
#keyframes ani01{
0%{
transform: rotate(0deg);
}
100%{
transform: rotate(360deg);
}
}
.section-title{
flex: 0 0 100%;
max-width: 100%;
margin-bottom: 60px;
padding: 0 15px;
}
.section-title h1{
display: inline-block;
font-size: 40px;
color: #000000;
font-weight: 700;
margin: 0;
position: relative;
}
.section-title h1:before{
content: '';
box-sizing: border-box;
position: absolute;
left: 0;
bottom: -5px;
width: 80px;
height: 3px;
background-color: #ff9800;
}
.btn-01{
background-color: #ff9800;
color: #fff;
border: 2px solid transparent;
padding: 10px 35px;
border-radius: 30px;
line-height: 1.5;
cursor: pointer;
text-decoration: none;
font-size: 16px;
font-weight: 600;
display: inline-block;
transition: all 0.5s ease;
}
.btn-01:hover{
background-color: transparent;
border-color: #FF9800;
color:#ff9800;
}
.btn-01:focus{
outline: none;
}
/* preloader */
/*.preloader{
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
background-color: #111111;
z-index: 1099;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.6 ease;
}*/
.preloader.loaded{
visibility: hidden;
opacity: 0;
z-index: -99;
}
.preloader.loader{
height: 30px;
width: 30px;
border: 2px solid #FF9800;
border-right: 2px solid transparent;
border-radius: 50%;
animation: ani01 2s linear infinite;
}
/*Header*/
.header{
position: absolute;
left: 0;
top:0;
width: 99;
transition: all 0.5s ease;
}
.header .fixed{
background-color: #fff;
position: fixed;
}
.header .brand-name{
padding: 0 15px;
}
.header.brand-name a{
text-decoration: none;
font-size: 30px;
color: #fff;
text-transform: uppercase;
font-weight: 900;
letter-spacing: 2px;
transition: all 0.5s ease;
}
.header .fixed .brand-name a{
color: #0000;
}
.header .nav-toggle{
width: 40px;
height: 34px;
border: 1px solid #fff;
border-radius: 3px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.5s ease;
display: none;
}
.header .fixed .nav-toggle {
border-color: #000;
}
.header .nav-toggle span{
height: 1px;
display: block;
width: 16px;
background-color: #fff;
position: relative;
transition: all 0.5s ease;
}
.header .nav-toggle span::before,
.header .nav-toggle span::after{
content: '';
position: absolute;
left: 0;
top: 0;
height: 1px;
width: 100%;
background-color: #fff;
transition: all 0.5s ease;
}
.header .fixed .nav-toggle span,
.header .fixed .nav-toggle:before,
.header .fixed .nav-toggle::after{
background-color: #000000;
}
.header .nav-toggle span:before{
transform: translate(-6px);
}
.header .nav-toggle span:after{
transform: translate(6px);
}
.header .nav{
padding: 0 15px;
}
.header.nav ul{
list-style:none;
margin:0;
padding:0;
}
.header .nav ul li{
display: inline-block;
margin-left: 30px;
}
.header .nav ul li a {
text-decoration: none;
font-size: 16px;
font-weight: 600;
color: #ffffff;
padding: 25px 0;
display: block;
transition: all 0.5s ease;
}
.header .fixed .nav ul li a{
color: #000000;
}
.header .fixed .nav ul li a:hover,
.header .nav ul li a:hover{
color: #FF9800;
}
/* Home Section */
.home-section{
min-height: 100vh;
background-image: url('./img/moviebg.jpg');
background-size: cover;
background-position: center;
position: relative;
z-index: 1;
padding: 0 15px;
}
.home-section:before{
content: '';
position: absolute;
box-sizing: border-box;
left: 0;
top: 0;
right: 0;
bottom: 0;
background-color: #000000;
opacity: 0.7;
z-index: -1;
}
.home-section .shape-01{
position:absolute;
height: 30px;
width:30px;
border: 2px solid #FF9800;
right: 5%;
top: 20%;
animation: ani01 5s linear infinite;
}
.home-section .row{
min-height: 100vh;
}
.home-section .home-content{
flex: 0 0 100%;
max-width: 100%;
text-align: center;
}
.home-section.home-content h4{
font-size: 20px;
color: #ffffff;
margin: 0;
}
.home-section .home-content h2{
font-size: 60px;
margin: 0;
color: #ffffff;
text-transform: uppercase;
font-weight: 900;
letter-spacing: 10px;
}
.home-section .scroll-down{
position: absolute;
left: 50%;
bottom: 30px;
height: 30px;
width: 30px;
margin-left: -15px;
animation: scrollDown 2s ease infinite;
}
#keyframes scrollDown{
0%,20%,50%,80%,100%{
transform: translateY(0);
}
40%{
transform: translateY(-30px);
}
60%{
transform: translateY(-15px);
}
}
.home-section .scroll-down img{
width: 25px;
display: block;
margin: 2px auto;
}
.about-section {
padding: 80px 0 0;
}
.about-section .about-img{
flex: 0 0 33.33%;
max-width: 33.33%;
padding: 0 15px;
}
.about-section .about-img .img-box{
position: relative;
}
.about-section .about-img .img-box .shape-02{
position: absolute;
height: 30px;
width: 30px;
border: 2px solid #FF9800;
left: 30px;
top: 30px;
animation: ani01 5s linear infinite;
}
.about-section .about-img .img-box img{
width: 100%;
display: block;
}
.about-section .about-content{
flex: 0 0 66.66%;
max-width: 66.66%;
padding: 0 15px;
}
.about-section .section-title{
margin-bottom: 30px;
padding: 0;
}
.about-section .about-content p{
font-size: 16px;
color: #555555;
line-height: 26px;
margin: 0;
}
.about-section .about-content .stats .stat-box{
flex: 0 0 25%;
max-width: 25%;
padding: 0 15px;
text-align: center;
margin-top: 30px;
}
.about-section.about-content.stats.stat-box h2{
font-size: 40px;
color: #000000;
margin: 0 0 5px;
}
.about-section .about-content .stats .stat-box h5{
font-size: 16px;
color: #555555;
font-weight: 600;
text-transform: uppercase;
}
.about-section .about-content .btn{
margin-top: 30px;
}
/*Categories*/
.service-section {
padding: 80px 0;
}
.service-section .service-item{
flex: 0 0 33.33%;
max-width: 33.33%;
padding: 15px;
}
.service-section .service-item-inner{
position: relative;
overflow: hidden;
}
.service-section .service-item-inner {
position: relative;
overflow: hidden;
}
.service-section .service-item-inner img{
width: 100%;
display: block;
filter:grayscale(100%);
transition: all 0.5s ease;
}
.service-section .service-item-inner:hover img{
filter:grayscale(0);
transform: scale(1.1);
}
.service-section .service-item-inner .overlay{
position: absolute;
left: 0;
top: 0;
height: 100%;
width: 100%;
background-color: rgba(0,0,0,0.6);
display: flex;
align-items: center;
justify-content: center;
transition: all 0.5s ease;
}
.service-section .service-item-inner:hover .overlay{
background-color: transparent;
}
.service-section .service-item-inner .overlay h3{
color: #ffffff;
font-size: 30px;
margin: 0;
text-align: center;
transition: all 0.5s ease;
text-transform: capitalize;
}
.service-section .service-item-inner .overlay:hover h4{
transform: translateX(30px);
opacity: 0;
}
/* Top-Rated*/
.work-section{
padding: 80px 0 0;
}
.work-section .work-item {
flex: 0 0 33.33%;
max-width: 33.33%;
padding: 15px;
}
.work-section .work-item-inner img{
width: 100%;
display: block;
transform: scale(1.1);
}
.work-section .work-item-inner:hover img{
filter: grayscale(100);
transform: scale(1);
}
.work-section .work-item-inner{
position: relative;
cursor: pointer;
overflow: hidden;
}
.work-section .work-item-inner .overlay{
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
padding: 15px;
display: flex;
align-items: flex-end;
transition: all 0.5s ease;
background-color: rgba(0,0,0,0.6);
opacity: 0;
}
.work-section .work-item-inner:hover .overlay{
opacity: 1;
}
.work-section .work-item-inner:hover .overlay h4{
color: #ffffff;
font-size: 20px;
margin: 0;
transform: translateX(30px);
transition: all 0.5s ease;;
}
.work-section .work-item-inner:hover .overlay h4{
transform: translateX(0);
}
<body>
<!--preloader-->
<div class="preloader">
<div class="loader"></div>
</div>
<!--preloader ends-->
<!--Head section starts-->
<header class="header">
<div class="container">
<div class="row justify-content-between align-items-center">
<div class="brand-name">
Movie Mania
</div>
<div class="nav-toggle">
<span></span>
</div>
<nav class="nav">
<ul>
<li>Home</li>
<li>About</li>
<li>Categories</li>
<li>Top-Rated</li>
<li>Contact</li>
</ul>
</nav>
</div>
</div>
</header>
<!-- Header end -->
<!-- Home Section starts -->
<section class="home-section" id="home">
<div class="shape-01">
</div>
<div class="container">
<div class="row align-items-center">
<div class="home-content">
<h4>Download your favourite movie in just a click</h4>
<h2>Welcome to Movie Mania</h2>
</div>
</div>
<!--Scroll Down-->
<a href="#about" class="scroll-down">
<img src="https://i.postimg.cc/vHVsxYMk/arrow-down.png" alt="scroll down">
</a>
</div>
</section>
<!-- Home section end -->
<!-- About section start -->
<section class="about-section" id="about">
<div class="container">
<div class="row">
<div class="about-img">
<div class="img-box">
<div class="shape-02"></div>
<img src="https://i.postimg.cc/76tk0b58/about.jpg" width = "30" height = "auto" alt="About US">
</div>
</div>
<div class="about-content">
<div class="row">
<div class="section-title">
<h1>About Us</h1>
</div>
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. </p>
<div class="stats">
<div class="row">
<div class="stat-box">
<h2>150K+</h2>
<h5>Daily Downloads</h5>
</div>
<div class="stat-box">
<h2>2500+</h2>
<h5>Movies Available</h5>
</div>
<div class="stat-box">
<h2>1M+</h2>
<h5>Happy Clients</h5>
</div>
</div>
</div>
<!--Contact Button-->
Contact Us
</div>
</div>
</div>
</section>
<!--About us ends -->
<!--Categories section start-->
<section class="service-section" id="categories">
<div class="container">
<div class="row">
<div class="section-title">
<h1>Categories</h1>
</div>
</div>
<div class="row">
<!--categories start-->
<div class="service-item">
<div class="service-item-inner">
<img src="https://i.postimg.cc/YShKkMXd/1.jpg" alt="category 1" width = "300" height = "auto">
<div class="overlay">
<h3>Ha Noi</h3>
</div>
</div>
</div>
<div class="service-item">
<div class="service-item-inner">
<img src="https://i.postimg.cc/1z2x322s/2.jpg" alt="category 2" width = "300" height = "auto">
<div class="overlay">
<h3>Hai Phong</h3>
</div>
</div>
</div>
<div class="service-item">
<div class="service-item-inner">
<img src="https://i.postimg.cc/BQBGBhLB/3.jpg" alt="category 3" width = "300" height = "auto">
<div class="overlay">
<h3>Nam Dinh</h3>
</div>
</div>
</div>
<div class="service-item">
<div class="service-item-inner">
<img src="https://i.postimg.cc/XY2STpgZ/4.jpg" alt="category 4" width = "300" height = "auto">
<div class="overlay">
<h3>Thanh Hoa</h3>
</div>
</div>
</div>
<div class="service-item">
<div class="service-item-inner">
<img src="https://i.postimg.cc/28DDvp65/5.jpg" alt="category 5" width = "300" height = "auto">
<div class="overlay">
<h3>Vinh</h3>
</div>
</div>
</div>
<div class="service-item">
<div class="service-item-inner">
<img src="https://i.postimg.cc/jSqYgzy0/6.jpg" alt="category 6" width = "300" height = "auto">
<div class="overlay">
<h3>Hue</h3>
</div>
</div>
</div>
</div>
</div>
</section>
<!--Category section ends-->
<!--Top rated section start-->
<section class="work-section" id="top">
<div class="container">
<div class="row">
<div class="section-title">
<h1>Top-Rated Movies</h1>
</div>
</div>
<div class="row">
<div class="work-item">
<div class="work-item-inner">
<img src="https://i.postimg.cc/854hHgGV/1.jpg" width = "300" height = "auto" data-large="./img/works/large/1.png" alt="Movie 1">
<div class="overlay">
<h4>Paris</h4>
</div>
</div>
</div>
</div>
<div class="row">
<div class="work-item">
<div class="work-item-inner">
<img src="https://i.postimg.cc/jjz6DJk2/2.jpg" width = "300" height = "auto" data-large="./img/works/large/2.png" alt="Movie 1">
<div class="overlay">
<h4>Berlin</h4>
</div>
</div>
</div>
</div>
<div class="row">
<div class="work-item">
<div class="work-item-inner">
<img src="https://i.postimg.cc/sXsY7Dtc/3.jpg" width = "300" height = "auto" data-large="./img/works/large/3.jpg" alt="Movie 1">
<div class="overlay">
<h4>Vill</h4>
</div>
</div>
</div>
</div>
<div class="row">
<div class="work-item">
<div class="work-item-inner">
<img src="https://i.postimg.cc/PqGzfMy0/4.jpg" width = "300" height = "auto" data-large="./img/works/large/4.jpg" alt="Movie 1">
<div class="overlay">
<h4>Thuong Hai</h4>
</div>
</div>
</div>
</div>
<div class="row">
<div class="work-item">
<div class="work-item-inner">
<img src="https://i.postimg.cc/65mfgKvW/5.jpg" width = "300" height = "auto" data-large="./img/works/large/5.jpg" alt="Movie 1">
<div class="overlay">
<h4>Bac Kinh</h4>
</div>
</div>
</div>
</div>
<div class="row">
<div class="work-item">
<div class="work-item-inner">
<img src="https://i.postimg.cc/jSn4r1Hz/6.jpg" width = "300" height = "auto" data-large="./img/works/large/6.png" alt="Movie 1">
<div class="overlay">
<h4>Trung Khanh</h4>
</div>
</div>
</div>
</div>
</div>
</section>
<!--top rated end -->
<!--contact section start-->
<section class="contact-section" id="contact">
<div class="container">
<div class="row">
<div class="img-box">
<div class="section-title">
<h1>Contact Us</h1>
</div>
</div>
</div>
</div>
<div class="row">
<div class="contact-form">
<form class="form">
<div class="row">
<div class="left input-group">
<label>Name</label>
<input type="text" placeholder="Your Name Here" class="input-control">
</div>
<div class="right input-group">
<label>Email or Phone</label>
<input type="text" placeholder="Your Email or Phone Here" class="input-control">
</div>
</div>
<div class="row">
<div class="left input-group">
<label>Message</label>
<textarea class="input-control" placeholder="Your Message Here"></textarea>
</div>
</div>
<div class="form-btn">
<button type="button" class="btn btn-01" id="button">Send Message</button>
</div>
<div id="dialog">
I know you know this, but you are awesome. As we say au revoir to another #ResearchPride month,
</div>
</form>
</div>
</div>
<div class="row">
<div class="contact-info">
<div class="row">
<div class="info-item">
<h5>Address</h5>
<p>X5 T7 U8 USA</p>
</div>
<div class="info-item">
<h5>Phone</h5>
<p>090 8403 1789</p>
</div>
<div class="info-item">
<h5>Email</h5>
<p>maviemanie#mivie.com</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="social-links">
<img src="https://i.postimg.cc/6Q9JPCRx/facebook.png" width = "100" height = "auto" alt="facebook">
<img src="https://i.postimg.cc/zBvmz50d/twitter.png" width = "100" height = "auto" alt="twitter">
<img src="https://i.postimg.cc/7Pc4LGvS/linkedin.png" width = "100" height = "auto" alt="linkedin">
<img src="https://i.postimg.cc/rsdLJc4d/intagram.jpg" width = "200" height = "auto" alt="intagram">
</div>
</div>
</section>
<p class="copyright">© 2022 Movie Mania</p>
<!--light box start-->
<div class="lightbox">
<div class="img-box">
<div class="lightbox-close">×</div>
<img src="https://i.postimg.cc/qML93zSm/2.png" width = "100" height = "auto" class="lightbox-img" alt="img1">
<div class="lightbox-caption">
<div class="lightbox-category">
</div>
<div class="lightbox-counter">
</div>
</div>
<div class="lightbox-controls">
<div class="prev">
<img src="https://i.postimg.cc/W4XLct6F/previous.png" width = "100" height = "auto" alt="previous">
</div>
<div class="next">
<img src="https://i.postimg.cc/QdZrp2dt/next.png" width = "100" height = "auto" alt="next">
</div>
</div>
</div>
</div>
<!--light box end -->
</body>
#import url('https://fonts.googleapis.com/css?family=Raleway:300,400,700&display=swap');
body{
margin: 0;
line-height: 1.5;
background-color: #f3f2f1;
}
body,
input,textarea,
button{
font-family: 'Raleway', 'sans-serif';
font-weight: 400;
}
*{
box-sizing: border-box;
margin: 0;
}
.container{
max-width: 1170px;
margin: auto;
}
.row{
display: flex;
flex-wrap: wrap;
}
.align-items-center{
align-items: center;
}
.justify-content-between{
justify-content: space-between;
}
#keyframes ani01{
0%{
transform: rotate(0deg);
}
100%{
transform: rotate(360deg);
}
}
.section-title{
flex: 0 0 100%;
max-width: 100%;
margin-bottom: 60px;
padding: 0 15px;
}
.section-title h1{
display: inline-block;
font-size: 40px;
color: #000000;
font-weight: 700;
margin: 0;
position: relative;
}
.section-title h1:before{
content: '';
box-sizing: border-box;
position: absolute;
left: 0;
bottom: -5px;
width: 80px;
height: 3px;
background-color: #ff9800;
}
.btn-01{
background-color: #ff9800;
color: #fff;
border: 2px solid transparent;
padding: 10px 35px;
border-radius: 30px;
line-height: 1.5;
cursor: pointer;
text-decoration: none;
font-size: 16px;
font-weight: 600;
display: inline-block;
transition: all 0.5s ease;
}
.btn-01:hover{
background-color: transparent;
border-color: #FF9800;
color:#ff9800;
}
.btn-01:focus{
outline: none;
}
/* preloader */
/*.preloader{
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
background-color: #111111;
z-index: 1099;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.6 ease;
}*/
.preloader.loaded{
visibility: hidden;
opacity: 0;
z-index: -99;
}
.preloader.loader{
height: 30px;
width: 30px;
border: 2px solid #FF9800;
border-right: 2px solid transparent;
border-radius: 50%;
animation: ani01 2s linear infinite;
}
/*Header*/
.header{
position: absolute;
left: 0;
top:0;
width: 99;
transition: all 0.5s ease;
}
.header .fixed{
background-color: #fff;
position: fixed;
}
.header .brand-name{
padding: 0 15px;
}
.header.brand-name a{
text-decoration: none;
font-size: 30px;
color: #fff;
text-transform: uppercase;
font-weight: 900;
letter-spacing: 2px;
transition: all 0.5s ease;
}
.header .fixed .brand-name a{
color: #0000;
}
.header .nav-toggle{
width: 40px;
height: 34px;
border: 1px solid #fff;
border-radius: 3px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.5s ease;
display: none;
}
.header .fixed .nav-toggle {
border-color: #000;
}
.header .nav-toggle span{
height: 1px;
display: block;
width: 16px;
background-color: #fff;
position: relative;
transition: all 0.5s ease;
}
.header .nav-toggle span::before,
.header .nav-toggle span::after{
content: '';
position: absolute;
left: 0;
top: 0;
height: 1px;
width: 100%;
background-color: #fff;
transition: all 0.5s ease;
}
.header .fixed .nav-toggle span,
.header .fixed .nav-toggle:before,
.header .fixed .nav-toggle::after{
background-color: #000000;
}
.header .nav-toggle span:before{
transform: translate(-6px);
}
.header .nav-toggle span:after{
transform: translate(6px);
}
.header .nav{
padding: 0 15px;
}
.header.nav ul{
list-style:none;
margin:0;
padding:0;
}
.header .nav ul li{
display: inline-block;
margin-left: 30px;
}
.header .nav ul li a {
text-decoration: none;
font-size: 16px;
font-weight: 600;
color: #ffffff;
padding: 25px 0;
display: block;
transition: all 0.5s ease;
}
.header .fixed .nav ul li a{
color: #000000;
}
.header .fixed .nav ul li a:hover,
.header .nav ul li a:hover{
color: #FF9800;
}
/* Home Section */
.home-section{
min-height: 100vh;
background-image: url('./img/moviebg.jpg');
background-size: cover;
background-position: center;
position: relative;
z-index: 1;
padding: 0 15px;
}
.home-section:before{
content: '';
position: absolute;
box-sizing: border-box;
left: 0;
top: 0;
right: 0;
bottom: 0;
background-color: #000000;
opacity: 0.7;
z-index: -1;
}
.home-section .shape-01{
position:absolute;
height: 30px;
width:30px;
border: 2px solid #FF9800;
right: 5%;
top: 20%;
animation: ani01 5s linear infinite;
}
.home-section .row{
min-height: 100vh;
}
.home-section .home-content{
flex: 0 0 100%;
max-width: 100%;
text-align: center;
}
.home-section.home-content h4{
font-size: 20px;
color: #ffffff;
margin: 0;
}
.home-section .home-content h2{
font-size: 60px;
margin: 0;
color: #ffffff;
text-transform: uppercase;
font-weight: 900;
letter-spacing: 10px;
}
.home-section .scroll-down{
position: absolute;
left: 50%;
bottom: 30px;
height: 30px;
width: 30px;
margin-left: -15px;
animation: scrollDown 2s ease infinite;
}
#keyframes scrollDown{
0%,20%,50%,80%,100%{
transform: translateY(0);
}
40%{
transform: translateY(-30px);
}
60%{
transform: translateY(-15px);
}
}
.home-section .scroll-down img{
width: 25px;
display: block;
margin: 2px auto;
}
.about-section {
padding: 80px 0 0;
}
.about-section .about-img{
flex: 0 0 33.33%;
max-width: 33.33%;
padding: 0 15px;
}
.about-section .about-img .img-box{
position: relative;
}
.about-section .about-img .img-box .shape-02{
position: absolute;
height: 30px;
width: 30px;
border: 2px solid #FF9800;
left: 30px;
top: 30px;
animation: ani01 5s linear infinite;
}
.about-section .about-img .img-box img{
width: 100%;
display: block;
}
.about-section .about-content{
flex: 0 0 66.66%;
max-width: 66.66%;
padding: 0 15px;
}
.about-section .section-title{
margin-bottom: 30px;
padding: 0;
}
.about-section .about-content p{
font-size: 16px;
color: #555555;
line-height: 26px;
margin: 0;
}
.about-section .about-content .stats .stat-box{
flex: 0 0 25%;
max-width: 25%;
padding: 0 15px;
text-align: center;
margin-top: 30px;
}
.about-section.about-content.stats.stat-box h2{
font-size: 40px;
color: #000000;
margin: 0 0 5px;
}
.about-section .about-content .stats .stat-box h5{
font-size: 16px;
color: #555555;
font-weight: 600;
text-transform: uppercase;
}
.about-section .about-content .btn{
margin-top: 30px;
}
/*Categories*/
.service-section {
padding: 80px 0;
}
.service-section .service-item{
flex: 0 0 33.33%;
max-width: 33.33%;
padding: 15px;
}
.service-section .service-item-inner{
position: relative;
overflow: hidden;
}
.service-section .service-item-inner {
position: relative;
overflow: hidden;
}
.service-section .service-item-inner img{
width: 100%;
display: block;
filter:grayscale(100%);
transition: all 0.5s ease;
}
.service-section .service-item-inner:hover img{
filter:grayscale(0);
transform: scale(1.1);
}
.service-section .service-item-inner .overlay{
position: absolute;
left: 0;
top: 0;
height: 100%;
width: 100%;
background-color: rgba(0,0,0,0.6);
display: flex;
align-items: center;
justify-content: center;
transition: all 0.5s ease;
}
.service-section .service-item-inner:hover .overlay{
background-color: transparent;
}
.service-section .service-item-inner .overlay h3{
color: #ffffff;
font-size: 30px;
margin: 0;
text-align: center;
transition: all 0.5s ease;
text-transform: capitalize;
}
.service-section .service-item-inner .overlay:hover h4{
transform: translateX(30px);
opacity: 0;
}
/* Top-Rated*/
.work-section{
padding: 80px 0 0;
}
.work-section .work-item {
flex: 0 0 33.33%;
max-width: 33.33%;
padding: 15px;
}
.work-section .work-item-inner img{
width: 100%;
display: block;
transform: scale(1.1);
}
.work-section .work-item-inner:hover img{
filter: grayscale(100);
transform: scale(1);
}
.work-section .work-item-inner{
position: relative;
cursor: pointer;
overflow: hidden;
}
.work-section .work-item-inner .overlay{
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
padding: 15px;
display: flex;
align-items: flex-end;
transition: all 0.5s ease;
background-color: rgba(0,0,0,0.6);
opacity: 0;
}
.work-section .work-item-inner:hover .overlay{
opacity: 1;
}
.work-section .work-item-inner:hover .overlay h4{
color: #ffffff;
font-size: 20px;
margin: 0;
transform: translateX(30px);
transition: all 0.5s ease;;
}
.work-section .work-item-inner:hover .overlay h4{
transform: translateX(0);
}
<body>
<!--preloader-->
<div class="preloader">
<div class="loader"></div>
</div>
<!--preloader ends-->
<!--Head section starts-->
<header class="header">
<div class="container">
<div class="row justify-content-between align-items-center">
<div class="brand-name">
Movie Mania
</div>
<div class="nav-toggle">
<span></span>
</div>
<nav class="nav">
<ul>
<li>Home</li>
<li>About</li>
<li>Categories</li>
<li>Top-Rated</li>
<li>Contact</li>
</ul>
</nav>
</div>
</div>
</header>
<!-- Header end -->
<!-- Home Section starts -->
<section class="home-section" id="home">
<div class="shape-01">
</div>
<div class="container">
<div class="row align-items-center">
<div class="home-content">
<h4>Download your favourite movie in just a click</h4>
<h2>Welcome to Movie Mania</h2>
</div>
</div>
<!--Scroll Down-->
<a href="#about" class="scroll-down">
<img src="https://i.postimg.cc/vHVsxYMk/arrow-down.png" alt="scroll down">
</a>
</div>
</section>
<!-- Home section end -->
<!-- About section start -->
<section class="about-section" id="about">
<div class="container">
<div class="row">
<div class="about-img">
<div class="img-box">
<div class="shape-02"></div>
<img src="https://i.postimg.cc/76tk0b58/about.jpg" width = "30" height = "auto" alt="About US">
</div>
</div>
<div class="about-content">
<div class="row">
<div class="section-title">
<h1>About Us</h1>
</div>
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. </p>
<div class="stats">
<div class="row">
<div class="stat-box">
<h2>150K+</h2>
<h5>Daily Downloads</h5>
</div>
<div class="stat-box">
<h2>2500+</h2>
<h5>Movies Available</h5>
</div>
<div class="stat-box">
<h2>1M+</h2>
<h5>Happy Clients</h5>
</div>
</div>
</div>
<!--Contact Button-->
Contact Us
</div>
</div>
</div>
</section>
<!--About us ends -->
<!--Categories section start-->
<section class="service-section" id="categories">
<div class="container">
<div class="row">
<div class="section-title">
<h1>Categories</h1>
</div>
</div>
<div class="row">
<!--categories start-->
<div class="service-item">
<div class="service-item-inner">
<img src="https://i.postimg.cc/YShKkMXd/1.jpg" alt="category 1" width = "300" height = "auto">
<div class="overlay">
<h3>Ha Noi</h3>
</div>
</div>
</div>
<div class="service-item">
<div class="service-item-inner">
<img src="https://i.postimg.cc/1z2x322s/2.jpg" alt="category 2" width = "300" height = "auto">
<div class="overlay">
<h3>Hai Phong</h3>
</div>
</div>
</div>
<div class="service-item">
<div class="service-item-inner">
<img src="https://i.postimg.cc/BQBGBhLB/3.jpg" alt="category 3" width = "300" height = "auto">
<div class="overlay">
<h3>Nam Dinh</h3>
</div>
</div>
</div>
<div class="service-item">
<div class="service-item-inner">
<img src="https://i.postimg.cc/XY2STpgZ/4.jpg" alt="category 4" width = "300" height = "auto">
<div class="overlay">
<h3>Thanh Hoa</h3>
</div>
</div>
</div>
<div class="service-item">
<div class="service-item-inner">
<img src="https://i.postimg.cc/28DDvp65/5.jpg" alt="category 5" width = "300" height = "auto">
<div class="overlay">
<h3>Vinh</h3>
</div>
</div>
</div>
<div class="service-item">
<div class="service-item-inner">
<img src="https://i.postimg.cc/jSqYgzy0/6.jpg" alt="category 6" width = "300" height = "auto">
<div class="overlay">
<h3>Hue</h3>
</div>
</div>
</div>
</div>
</div>
</section>
<!--Category section ends-->
<!--Top rated section start-->
<section class="work-section" id="top">
<div class="container">
<div class="row">
<div class="section-title">
<h1>Top-Rated Movies</h1>
</div>
</div>
<div class="row">
<div class="work-item">
<div class="work-item-inner">
<img src="https://i.postimg.cc/854hHgGV/1.jpg" width = "300" height = "auto" data-large="./img/works/large/1.png" alt="Movie 1">
<div class="overlay">
<h4>Paris</h4>
</div>
</div>
</div>
<div class="work-item">
<div class="work-item-inner">
<img src="https://i.postimg.cc/jjz6DJk2/2.jpg" width = "300" height = "auto" data-large="./img/works/large/2.png" alt="Movie 1">
<div class="overlay">
<h4>Berlin</h4>
</div>
</div>
</div>
<div class="work-item">
<div class="work-item-inner">
<img src="https://i.postimg.cc/sXsY7Dtc/3.jpg" width = "300" height = "auto" data-large="./img/works/large/3.jpg" alt="Movie 1">
<div class="overlay">
<h4>Vill</h4>
</div>
</div>
</div>
<div class="work-item">
<div class="work-item-inner">
<img src="https://i.postimg.cc/PqGzfMy0/4.jpg" width = "300" height = "auto" data-large="./img/works/large/4.jpg" alt="Movie 1">
<div class="overlay">
<h4>Thuong Hai</h4>
</div>
</div>
</div>
<div class="work-item">
<div class="work-item-inner">
<img src="https://i.postimg.cc/65mfgKvW/5.jpg" width = "300" height = "auto" data-large="./img/works/large/5.jpg" alt="Movie 1">
<div class="overlay">
<h4>Bac Kinh</h4>
</div>
</div>
</div>
<div class="work-item">
<div class="work-item-inner">
<img src="https://i.postimg.cc/jSn4r1Hz/6.jpg" width = "300" height = "auto" data-large="./img/works/large/6.png" alt="Movie 1">
<div class="overlay">
<h4>Trung Khanh</h4>
</div>
</div>
</div>
</div>
</div>
</section>
<!--top rated end -->
<!--contact section start-->
<section class="contact-section" id="contact">
<div class="container">
<div class="row">
<div class="img-box">
<div class="section-title">
<h1>Contact Us</h1>
</div>
</div>
</div>
</div>
<div class="row">
<div class="contact-form">
<form class="form">
<div class="row">
<div class="left input-group">
<label>Name</label>
<input type="text" placeholder="Your Name Here" class="input-control">
</div>
<div class="right input-group">
<label>Email or Phone</label>
<input type="text" placeholder="Your Email or Phone Here" class="input-control">
</div>
</div>
<div class="row">
<div class="left input-group">
<label>Message</label>
<textarea class="input-control" placeholder="Your Message Here"></textarea>
</div>
</div>
<div class="form-btn">
<button type="button" class="btn btn-01" id="button">Send Message</button>
</div>
<div id="dialog">
I know you know this, but you are awesome. As we say au revoir to another #ResearchPride month,
</div>
</form>
</div>
</div>
<div class="row">
<div class="contact-info">
<div class="row">
<div class="info-item">
<h5>Address</h5>
<p>X5 T7 U8 USA</p>
</div>
<div class="info-item">
<h5>Phone</h5>
<p>090 8403 1789</p>
</div>
<div class="info-item">
<h5>Email</h5>
<p>maviemanie#mivie.com</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="social-links">
<img src="https://i.postimg.cc/6Q9JPCRx/facebook.png" width = "100" height = "auto" alt="facebook">
<img src="https://i.postimg.cc/zBvmz50d/twitter.png" width = "100" height = "auto" alt="twitter">
<img src="https://i.postimg.cc/7Pc4LGvS/linkedin.png" width = "100" height = "auto" alt="linkedin">
<img src="https://i.postimg.cc/rsdLJc4d/intagram.jpg" width = "200" height = "auto" alt="intagram">
</div>
</div>
</section>
<p class="copyright">© 2022 Movie Mania</p>
<!--light box start-->
<div class="lightbox">
<div class="img-box">
<div class="lightbox-close">×</div>
<img src="https://i.postimg.cc/qML93zSm/2.png" width = "100" height = "auto" class="lightbox-img" alt="img1">
<div class="lightbox-caption">
<div class="lightbox-category">
</div>
<div class="lightbox-counter">
</div>
</div>
<div class="lightbox-controls">
<div class="prev">
<img src="https://i.postimg.cc/W4XLct6F/previous.png" width = "100" height = "auto" alt="previous">
</div>
<div class="next">
<img src="https://i.postimg.cc/QdZrp2dt/next.png" width = "100" height = "auto" alt="next">
</div>
</div>
</div>
</div>
<!--light box end -->
</body>
I have used flexbox already to try this, but for some reason it isn't working. On a smaller screen size, everything's centered. I tried doing justify-content: center for flexbox, but that isn't working. I will put down the code snippet as well as screen shots showing what I'm seeing. You may look at snippet, but it uses a combination of percents and pixels, so it may look weird. Can I handle simple centering without media queries? Even if I did use one, I still can't get it to center on my desktop.
html {
height: 100%;
}
body{
height: 100%;
margin: 0;
font-family: courier;
font-size: 19px;
}
#container {
min-height: 100%;
margin-bottom: -150px;
width: 100%;
}
#container:after {
content: "";
display: block;
}
#content{
display:flex;
float:left;
width: 800px;
flex-wrap: wrap;
justify-content: center;
}
#footer, #container:after{
height: 150px;
}
#footer{
background-color: #006699;
clear: both;
}
.wrap {
margin: 0 auto;
width: 100%;
display: flex;
align-items: center;
flex-wrap: nowrap;
}
.sub {
padding: 12px;
width: 32%;
height: 120px;
color: white;
border-right: solid white 1px;
}
.sub:last-child{
border: 0px;
}
#leftbar{
width: 10%;
height: calc(100vh - 150px);
background-color: black;
float:left;
}
#rightbar{
width: 10%;
height: calc(100vh - 150px);
background-color: black;
float: right;
}
#nav {
list-style: none;
font-weight: bold;
width: 100%;
text-align: center;
background: rgba(0, 102, 153, 0.4);
height: 100px;
}
#nav ul {
list-style-type: none;
margin: 0px;
padding: 0;
overflow: auto;
// background-color: #006699;
text-align: center;
}
#nav li {
margin: 0px;
display: inline-block;
}
#nav li a {
padding: 10px;
display: inline-block;
text-decoration: none;
font-weight: bold;
font-size: 30px;
color: white;
// background-color: #006699;
}
#nav li a:hover {
color: white;
text-shadow: 2px 2px 4px white;
}
.clear {
clear: both;
}
div.img {
margin: 5px;
border: 1px solid #595959;
float: left;
width: 180px;
}
div.img:hover{
border: 1px solid #b3b3ff;
}
div.img img {
width: 100%;
height: auto;
}
div.desc{
padding: 15px;
text-align: center;
}
div.head{
text-align:center;
background-color:black;
color: orange;
}
<!DOCTYPE HTML>
<html>
<head lang="en">
<link rel="stylesheet" type="text/css" href="new.css" />
<meta charset="UTF-8">
<title></title>
<style>
</style>
<script>
</script>
</head>
<body>
<div id="container">
<div id="nav">
<ul>
<li>Home</li>
<li>Works</li>
<li>About</li>
</ul>
</div>
<div class="clear"></div>
<div class="upperbox">
<div id="leftbar"> </div>
<div id="rightbar"></div>
<div id="content">
<div class="img">
<div class="head">Color Palettes</div>
<img src="purple.png" alt="the color purple">
<div class="desc">Color</div>
</div>
<div class="img">
<div class="head">Color Palettes</div>
<img src="blue.png" alt="the color blue">
<div class="desc">Color</div>
</div>
<div class="img">
<div class="head">Color Palettes</div>
<img src="yellow.png" alt="the color yellow">
<div class="desc">Color</div>
</div>
<div class="img">
<div class="head">Color Palettes</div>
<img src="brown.jpg" alt="the color yellow">
<div class="desc">Color</div>
</div>
<div class="img">
<div class="head">Color Palettes</div>
<img src="grey.jpg" alt="the color yellow">
<div class="desc">Color</div>
</div>
<div class="img">
<div class="head">Color Palettes</div>
<img src="green.png" alt="the color yellow">
<div class="desc">Color</div>
</div>
<div class="img">
<div class="head">Color Palettes</div>
<img src="red.png" alt="the color yellow">
<div class="desc">Color</div>
</div>
<div class="img">
<div class="head">Color Palettes</div>
<img src="gold.jpg" alt="the color yellow">
<div class="desc">Color</div>
</div>
</div>
</div>
</div>
<div id="footer">
<div class="wrap">
<div class="sub">Lorem Ipsum</div>
<div class="sub">Lorem Ipsum </div>
<div class="sub">Lorem Ipsum </div>
</div>
</div>
</body>
</html>
erase float:left; from #content and add margin: 0 auto to it.
You can either give your #content the CSS of margin: 0 auto;, like so:
#content {
margin: 0 auto;
}
(Maybe you will also have to not float it to the left)
Or you could take a look at other modern possibilities for centering an element:
https://css-tricks.com/centering-percentage-widthheight-elements/
https://css-tricks.com/centering-in-the-unknown/
https://codemyviews.com/blog/how-to-center-anything-with-css
I'm woring in this carousel, i'm using bootstram, and OWL Carousel : http://owlgraphic.com/owlcarousel
what i need to do is, make the clicked button taller, and in front of the image, like in the attached images.
HTML
<!-- owl carousol start -->
<div id="demo">
<div class="container">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div id="sync1" class="owl-carousel">
<div class="item">
<h1>Atentos, despiertos, <br/> llenos de energía</h1>
<img src="images/slider.png"/>
</div>
<div class="item">
<h1>Atentos, despiertos, <br/> llenos de energía</h1>
<img src="images/slider.png"/></div>
<div class="item">
<h1>Atentos, despiertos, <br/> llenos de energía</h1>
<img src="images/slider.png"/></div>
<div class="item">
<h1>Atentos, despiertos, <br/> llenos de energía</h1>
<img src="images/slider.png"/></div>
<div class="item">
<h1>Atentos, despiertos, <br/> llenos de energía</h1>
<img src="images/slider.png"/></div>
</div>
<div id="sync2" class="owl-carousel">
<div class="item"><h1>Un nuevo amanecer</h1></div>
<div class="item"><h1>Conoce Expo Digital</h1></div>
<div class="item"><h1>Expo Priority</h1></div>
<div class="item"><h1>Expo Gold</h1></div>
<div class="item"><h1>Expo at work</h1></div>
</div>
</div>
</div>
</div>
</div>
And the CSS
#sync1 .item{
background: #0c83e7;
padding: 0px 0px;
margin: 0px;
color: #FFF;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
text-align: center;
}
#sync2 .item{
background: #fff;
padding: 10px 0px;
margin: 0px;
color: #FFF;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
text-align: center;
cursor: pointer;
border-radius:0px;
margin-left:-5px;
border-left:1px solid #91c04e;
border: 1px solid red;
}
#sync2 .item:nth-child(6){
border:0px;
}
#sync2 .item h1{
font-size: 18px;
font-family: HelveticaNeueLight;
color:#9ac55d ;
}
#sync2 .synced .item{
background: #9ac55d;
color: #fff;
}
#sync2 .synced .item h1{
color: #fff;
font-family: HelveticaNeueLight;
}
#sync1 .item h1{
font-family: HelveticaNeueLight;
font-style: italic;
position: absolute;
width: 98%;
text-align: right;
font-size: 48px;
}
#sync1 .item img{
width: 100%;
}
.owl-item .item img{
width:100%;
overflow:hidden;
}
.owl-theme .owl-controls .owl-buttons div{
display:none;
}
.owl-wrapper{
width:1000px;
}
.owl-theme .owl-controls{
margin:0px;
}
#sync2{
z-index:9999999999999;
margin-top:0px;
}
#sync2 .synced .item{
color:#1c6f42;
border-right:1px solid #91c04e;
height: 55px;
margin: -10px 0px 0px 0px;
z-index: 99999999;
}
#sync2 .item{
color:#91c04e;
height:45px;
}
#demo .full_width{
max-width:100%;
overflow:hidden;
}
#sync2 .item a:active{
color:red;
height:55px;
background-color: white;
margin: 10px 1px 1px 1px;
z-index: 9999999;
}
What i need is to get this button taller and in fron of the main image.
that's why i'm coming here, because i had not found a solution in other palce.
This is the way i'm doing it:
and this is the way i need it working.
So i'm trying a lot of cases, but i still don't found the way to do it.
thank you for your help!
In css3 you have the scale propertie :
.item:hover{
transform: scale(2);
}
will make the hovered item 2 times bigger.
.item a:active{
transform: scale(2);
}
Feel free to ask if needed
I'm building the following (see image). Basically, I need 5 buttons with overlapping buttons (each with numbers) on the top. However, I'm unsure how to go about this?
One solution:
https://jsfiddle.net/ryd5e51n/
<div class="button">
<div class="button-top"><span class="text">1</span></div>
<div class="button-bottom"></div>
</div>
.button
{
display: table;
}
.button-top
{
background-color: black;
width: 36px;
height: 36px;
border-radius: 18px;
margin: auto;
position: relative;
z-index: 2;
box-shadow: 0px 0px 2px 2px #bbbbbb;
color: white;
text-align: center;
}
.text
{
display: block;
position: relative;
top: 50%;
transform: translateY(-50%);
}
.button-bottom
{
background-color: #efefef;
width: 100px;
height: 90px;
margin-top: -15px;
position: relative;
z-index: 1;
border: 2px solid #bbbbbb;
border-radius: 20px;
}
You can do this with a single element:
HTML:
<div class="button">
</div>
<div class="button">
</div>
<div class="button">
</div>
<div class="button">
</div>
<div class="button">
</div>
CSS:
div.button {
display:block;
float:left;
margin:18px 5px 0;
position:relative;
overflow:visible;
background:none #efefef;
width:100px;
height:100px;
border:2px solid #ccc;
border-radius:10px;
counter-increment: button;
}
div.button:before {
content:counter(button);
display:block;
padding:8px 14px;
background:none #000;
border:2px solid #ccc;
border-radius:100px;
color:#fff;
position:absolute;
left:50%;
top:-18px;
transform: translateX(-50%);
}
See fiddle: https://jsfiddle.net/jj2nk5f1/2/
Here it is.
.button {
float: left;
margin-left: 10px;
}
.number {
width: 20px;
height: 20px;
border-radius: 10px;
background-color: black;
margin-left: 15px;
}
.block {
width: 50px;
height: 50px;
border: 1px solid black;
margin-top: -10px;
}
<div class="button">
<div class="number"></div>
<div class="block"></div>
</div>
<div class="button">
<div class="number"></div>
<div class="block"></div>
</div>
<div class="button">
<div class="number"></div>
<div class="block"></div>
</div>
<div class="button">
<div class="number"></div>
<div class="block"></div>
</div>
<div class="button">
<div class="number"></div>
<div class="block"></div>
</div>
Please take a look at the picture provided above, each box is a div which is working fine, but in some cases the div labelled "BIG BOX" creates some free space on each line.
Is there is anyway to fill the free area with my current css setup:
.topic_box_small{
z-index:3;
outline: red solid 1px;
display: block;
position: relative;
float:left;
width:115px;
height:115px;
overflow: no-content;
background-color: burlywood;
box-shadow: #999999 0px 0px 2px ;
border-radius:5px;
margin:5px;
}
.topic_box_medium{
z-index:3;
outline: red solid 1px;
display: block;
position: relative;
float: left;
width:240px;
height:115px;
overflow: no-content;
background-color: palegreen;
box-shadow: #999999 0px 0px 2px ;
border-radius:5px;
margin:5px;
}
.topic_box_large{
z-index:3;
outline: red solid 1px;
display: block;
position: relative;
float: left;
width:240px;
height:240px;
overflow: no-content;
background-color: orange;
box-shadow: #999999 0px 0px 2px ;
border-radius:5px;
margin:5px;
}
.category_Heading{
z-index:3;
display: block;
position: relative;
width: 100%;
text-height: 20px;
padding: 5px;
font-size: 15px;
text-align: center;
clear:both;
background-color: #fff;
color:brown;
box-shadow: #999999 0px 0px 2px ;
}
.topic_Wrapper{
display: block;
width: auto;
height: auto;
margin: 5px;
}
HTML
<section class="content_packet">
<h2 class="category_Heading">Category 1 </h2>
<div class="topic_Wrapper" >
<div class="topic_box_medium"> <P>MEDIUM BOX<P> </div>
<div class="topic_box_medium"> <P>MEDIUM BOX<P> </div>
<div class="topic_box_large"> <P>BIG BOX<P> </div>
<div class="topic_box_large"> <P>BIG BOX<P> </div>
<div class="topic_box_mini"> <P>MINI BOX<P> </div>
<div class="topic_box_mini"> <P>MINI BOX<P> </div>
<div class="topic_box_mini"> <P>MINI BOX<P> </div>
<div class="topic_box_mini"> <P>MINI BOX<P> </div>
<div class="topic_box_mini"> <P>MINI BOX<P> </div>
<div class="topic_box_mini"> <P>MINI BOX<P> </div>
<div class="topic_box_mini"> <P>MINI BOX<P> </div>
<div class="topic_box_mini"> <P>MINI BOX<P> </div>
</div>
<h2 class="category_Heading">Category 1 </h2>
<div class="topic_Wrapper" >
<div class="topic_box_large"> </div>
<div class="topic_box_large"></div>
<div class="topic_box_mini"></div>
<div class="topic_box_mini"> </div>
<div class="topic_box_normal"> </div>
<div class="topic_box_medium"></div>
<div class="topic_box_mini"></div>
<div class="topic_box_mini"> </div>
</div>
</section>
You can use more than one CSS class in your tags, Just add a space between them like so.
<div class="CSS-Class1 CSS-Class-2 CSS-Class-3">...</div>
CSS:
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
/* force scrollbar, prevents initial gap */
html {
overflow-y: scroll;
}
body {
font-family: sans-serif;
}
/* ---- grid ---- */
.grid {
background: #DDD;
}
/* clear fix */
.grid:after {
content: '';
display: block;
clear: both;
}
/* ---- .element-item ---- */
/* 5 columns, percentage width */
.grid-item,
.grid-sizer {
width: 20%;
}
.grid-item {
float: left;
height: 100px;
background: #0D8;
border: 2px solid #333;
border-color: hsla(0, 0%, 0%, 0.7);
}
.grid-item--width2 { width: 40%; }
.grid-item--height2 { height: 200px; }
HTML
<div class="grid">
<div class="grid-sizer"></div>
<div class="grid-item grid-item--width2"></div>
<div class="grid-item grid-item--height2"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item grid-item--width2 grid-item--height2"></div>
<div class="grid-item grid-item--width2"></div>
<div class="grid-item grid-item--width2"></div>
<div class="grid-item grid-item--height2"></div>
<div class="grid-item"></div>
<div class="grid-item grid-item--width2"></div>
<div class="grid-item grid-item--height2"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
</div>
The Masonry layout is the way to go as said in the comments, but because you want to have different widths you will have to use some java-script.
Here is a good site to look at. http://isotope.metafizzy.co/layout-modes/masonry.html
And a Codepen Example to see how it works. http://codepen.io/desandro/pen/sqrwo
Hope this helps
This post may help you.
Where you can calculate tallest div and set the same height for each div.