Flex Divs won't align even though they have the same height - html

I'm having a problem where divs won't stay on the top of their parent-div if the image they contain doesn't have the same height as the others ones.
In my navbar I have icons of different sizes, I put them in divs on which I use display: flex to verticlly align the icons inside the divs. The divs all have the same height, but if the image of each div isn't identical, a small margin appear above them, as seen in this snippet :
#navbar-right {
position: absolute;
top: 10px;
right: 300px;
margin: 0;
padding: 0;
font-family: 'Comfortaa', cursive;
font-size: 0px;
line-height: 1;
color: #3F3F3F;
border: 1px solid blue;
}
#navbar-right .navbar-menu {
position: relative;
display: inline-flex;
align-items: center;
height: 35px;
border: 1px solid red;
margin: 0;
padding: 0;
}
<div id="navbar-right">
<a href="#">
<div id="menu-language" class="navbar-menu">
<img src="/core/img/language.png" width="36" height="24"/>
</div>
</a>
<a href="#">
<div id="menu-language" class="navbar-menu">
<img src="/core/img/language.png" width="36" height="20"/>
</div>
</a>
<a href="#">
<div id="menu-language" class="navbar-menu">
<img src="/core/img/language.png" width="36" height="30"/>
</div>
</a>
</div>
I don't understand why this happens nor how to fix it. Any ideas ?

You have to add display: flex to the container:
#navbar-right {
display: flex;
position: absolute;
top: 10px;
right: 300px;
margin: 0;
padding: 0;
font-family: 'Comfortaa', cursive;
font-size: 0px;
line-height: 1;
color: #3F3F3F;
border: 1px solid blue;
}
#navbar-right .navbar-menu {
position: relative;
display: inline-flex;
align-items: center;
height: 35px;
border: 1px solid red;
margin: 0;
padding: 0;
}
<div id="navbar-right">
<a href="#">
<div id="menu-language" class="navbar-menu">
<img src="/core/img/language.png" width="36" height="24"/>
</div>
</a>
<a href="#">
<div id="menu-language" class="navbar-menu">
<img src="/core/img/language.png" width="36" height="20"/>
</div>
</a>
<a href="#">
<div id="menu-language" class="navbar-menu">
<img src="/core/img/language.png" width="36" height="30"/>
</div>
</a>
</div>

It seems that if you add a vertical-align: middle; to the .navbar-menu class, it does the job.
#navbar-right {
position: absolute;
top: 10px;
right: 300px;
margin: 0;
padding: 0;
font-family: 'Comfortaa', cursive;
font-size: 0px;
line-height: 1;
color: #3F3F3F;
border: 1px solid blue;
}
#navbar-right .navbar-menu {
position: relative;
display: inline-flex;
align-items: center;
vertical-align: middle;
height: 35px;
border: 1px solid red;
margin: 0;
padding: 0;
}
<div id="navbar-right">
<a href="#">
<div id="menu-language" class="navbar-menu">
<img src="/core/img/language.png" width="36" height="24"/>
</div>
</a>
<a href="#">
<div id="menu-language" class="navbar-menu">
<img src="/core/img/language.png" width="36" height="20"/>
</div>
</a>
<a href="#">
<div id="menu-language" class="navbar-menu">
<img src="/core/img/language.png" width="36" height="30"/>
</div>
</a>
</div>

Remove display:inline-flex from .navbar-menu and add it to main container:
#navbar-right{
display:inline-flex;
}
#navbar-right {
position: absolute;
display:inline-flex;
top: 10px;
right: 300px;
padding: 10px;
font-family: 'Comfortaa', cursive;
border: 1px solid blue;
}
.navbar-menu {
position: relative;
height: 35px;
border: 1px solid red;
}
<div id="navbar-right">
<a href="#">
<div id="menu-language" class="navbar-menu">
<img src="/core/img/language.png" width="36" height="24"/>
</div>
</a>
<a href="#">
<div id="menu-language" class="navbar-menu">
<img src="/core/img/language.png" width="36" height="20"/>
</div>
</a>
<a href="#">
<div id="menu-language" class="navbar-menu">
<img src="/core/img/language.png" width="36" height="30"/>
</div>
</a>
</div>

Related

How to define new division class after lightbox gallery and create footer?

I have given header, a menu bar and a hero image, after that created image gallery using lightbox. I have create 4 columns with 3 images each, but in the lightbox gallery it's showing 3 columns with 4 images each.
I have given new row called My Videos but the css taking the previous row into consideration not the new one. I placed a video but it's not moving according to the margins given.
Lastly, my footer is not showing up..
<!doctype html>
<html>
<head>
<title> Project One </title>
<link rel="stylesheet" href="C:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/main.css">
<link rel="stylesheet" href="C:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/lightbox.css">
</head>
<body>
<header>
<div class="header-section">
<div class="header-logo">
<h1> Superstar </h1>
</div>
<div class="header-right">
<p> Plot No.33,Mahalaxmi Nagar, Vizianagaram-535 002.<br>
email:saisankarmandala#gmail.com.
</p>
</div>
</div>
</header>
<nav>
<ul>
<li>Home</li>
<li>Products</li>
<li>Blog</li>
<li>Contact Us</li>
</ul>
</nav>
<div class="container"></div>
<div class="hero-text">
<h1> I am Creative </h1>
</div>
<div class="row">
<h1> My Gallery </h1>
</div>
<div class="col col-md-8-pushdown-sm">
<div class="column">
<div class="thumbnails">
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb1.jpg" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb1a.jpg" width="200" height="200"></a>
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb2.jpg" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb2a.jpg" width="200" height="200"></a>
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb3.jpg" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb3a.jpg" width="200" height="200"></a>
</div>
</div>
<div class="column">
<div class="thumbnails">
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb4.jpg" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb4a.jpg" alt="thumb" width="200" height="200"></a>
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb5.png" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb5a.png" alt="thumb" width="200" height="200"></a>
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb6.jpg" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb6a.jpg" alt="thumb" width="200" height="200"></a>
</div>
</div>
<div class="column">
<div class="thumbnails">
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb7.jpg" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb7a.jpg" alt="thumb" width="200" height="200"></a>
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb8.jpg" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb8a.jpg" alt="thumb" width="200" height="200"></a>
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb9.jpg" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb9a.jpg" alt="thumb" width="200" height="200"></a>
</div>
</div>
<div class="column">
<div class="thumbnails">
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb10.jpeg" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb10a.jpeg" alt="thumb" width="200" height="200"></a>
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb11.jpg" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb11a.jpg" alt="thumb" width="200" height="200"></a>
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb12.png" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb12a.png" alt="thumb" width="200" height="200"></a>
</div>
</div>
</div>
<div class="row">
<div class="heading">
<h1> My Videos </h1>
</div>
</div>
<div class="column">
<div class="video-area">
<video height="150" width="200" controls>
<source src="C:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/vids/vid1.mp4" type="video/mp4" >
<source src="C:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/vids/vid2.mp4" type="video/mp4">
</video>
</div>
</div>
<div class="clearfix"></div>
<footer>
<p>&copy 2021, All rights reserved </p>
</footer>
<script type="text/javascript" src="C:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/lightbox-plus-jquery.js"></script>
</body>
</html>
This is my CSS Code
html {
height: 100%;
}
body {
position: relative;
margin: 0;
height: 100%;
}
/*styling the header section */
.header-section {
display: flex;
flex-wrap: wrap;
border-bottom: 2px solid purple;
background-color: purple;
margin-bottom: 0;
overflow: auto;
}
/* divide the header area into two and make width adjustments */
.header-logo {
width: 66%;
float: left;
flex: 1;
}
h1 {
font-family: Helvetica, arial, sans-serif;
font-size: 300%;
color: #fff;
font-weight: bold;
padding: 10px 0px 0px 40px;
box-sizing: border-box;
}
.header-right {
width: 34%;
float: right;
flex: 1;
}
p {
font-size: 110%;
font-weight: bold;
color: #fff;
padding: 40px 0px 0px 150px;
box-sizing: border-box;
}
nav li {
list-style: none;
float: left;
display: inline;
margin-top: -5px;
}
nav {
float: left;
margin-top: 0px;
bottom-border: none;
border-top: 0px solid purple;
width: 100%;
background-color: purple;
width: 100%;
height: 42px;
overflow: hidden;
}
nav a {
color: white;
text-decoration: none;
}
nav a {
display: inline;
font-family: Helvetica, arial, sans-serif;
text-decoration: none;
padding: 10px 20px;
border: 1px solid white;
border-bottom: 1px;
border-spacing: 3px;
background-color: purple;
color: white;
margin-right: 2px;
margin-top: -2px;
}
/* hero image area */
.container {
max-width: 100%;
margin-top: 45px;
background-image: url('C:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/nude.jpg');
height: 75%;
position: relative;
background-repeat: no-repeat;
background-size: cover;
background-position: right center;
}
/* hero text on the image */
.hero-text {
background-color: rgba(0, 0, 0, 0.4);
/* Black w/opacity/see-through */
color: purple;
font-weight: bold;
border: 3px solid #f1f1f1;
position: absolute;
top: 60%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 1000;
width: 80%;
padding: 30px;
text-align: center;
}
/* row heading */
.row h1 {
margin-top: -10px;
font-size: 150%;
font-family: Helvetica, arial, sans-serif;
font-weight: bold;
text-align: center;
color: #fff;
background-color: purple;
}
/* image gallery settings */
.column {
display: flex;
align-items: stretch;
column-gap: 20px;
}
.thumbnails img {
float: left;
width: 25%;
margin: 0 auto;
display: block;
max-width: 100%;
padding: 10px 20px 10px 30px;
margin-left: 40px;
margin-right: 10px;
margin-bottom: 15px;
transitiion: all 2s ease-in-out;
border: 1px solid grey;
box-sizing: border-box
}
.thumbnails img:hover {
transform: rotate(2deg);
box-shadow: 0 0 7px rgba(0, 0, 0, .5);
opacity: 1;
transform: scale(1)rotate(2deg);
.thumbnails:hover img {
opacity: .5;
transform: scale(.92);
}
.row::after {
content: "";
clear: both;
display: table;
}
.heading h1 {
font-size: 150%;
font-family: Helvetica, arial, sans-serif;
font-weight: bold;
text-align: center;
color: purple;
}
.video-area video {
margin: 0 auto;
display: block;
}
.footer {
position: fixed;
width: 100%;
bottom: 0;
}
html {
height: 100%;
}
body {
position: relative;
margin: 0;
height: 100%;
}
/*styling the header section */
.header-section {
display: flex;
flex-wrap: wrap;
border-bottom: 2px solid purple;
background-color: purple;
margin-bottom: 0;
overflow: auto;
}
/* divide the header area into two and make width adjustments */
.header-logo {
width: 66%;
float: left;
flex: 1;
}
h1 {
font-family: Helvetica, arial, sans-serif;
font-size: 300%;
color: #fff;
font-weight: bold;
padding: 10px 0px 0px 40px;
box-sizing: border-box;
}
.header-right {
width: 34%;
float: right;
flex: 1;
}
p {
font-size: 110%;
font-weight: bold;
color: #fff;
padding: 40px 0px 0px 150px;
box-sizing: border-box;
}
nav li {
list-style: none;
float: left;
display: inline;
margin-top: -5px;
}
nav {
float: left;
margin-top: 0px;
border-bottom: none;
border-top: 0px solid purple;
width: 100%;
background-color: purple;
width: 100%;
height: 42px;
overflow: hidden;
}
nav a {
color: white;
text-decoration: none;
}
nav a {
display: inline;
font-family: Helvetica, arial, sans-serif;
text-decoration: none;
padding: 10px 20px;
border: 1px solid white;
border-bottom: 1px;
border-spacing: 3px;
background-color: purple;
color: white;
margin-right: 2px;
margin-top: -2px;
}
/* hero image area */
.container {
max-width: 100%;
margin-top: 45px;
background-image: url('C:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/nude.jpg');
height: 75%;
position: relative;
background-repeat: no-repeat;
background-size: cover;
background-position: right center;
}
/* hero text on the image */
.hero-text {
background-color: rgba(0, 0, 0, 0.4);
/* Black w/opacity/see-through */
color: purple;
font-weight: bold;
border: 3px solid #f1f1f1;
position: absolute;
top: 60%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 1000;
width: 80%;
padding: 30px;
text-align: center;
}
/* row heading */
.row h1 {
margin-top: -10px;
font-size: 150%;
font-family: Helvetica, arial, sans-serif;
font-weight: bold;
text-align: center;
color: #fff;
background-color: purple;
}
/* image gallery settings */
.column {
display: flex;
align-items: stretch;
column-gap: 20px;
}
.thumbnails img {
float: left;
width: 25%;
margin: 0 auto;
display: block;
max-width: 100%;
padding: 10px 20px 10px 30px;
margin-left: 40px;
margin-right: 10px;
margin-bottom: 15px;
transition:all 2s ease-in-out;
border: 1px solid grey;
box-sizing: border-box
}
.thumbnails img:hover {
transform: rotate(2deg);
box-shadow: 0 0 7px rgba(0, 0, 0, .5);
opacity: 1;
transform: scale(1)rotate(2deg);
}
.thumbnails:hover img {
opacity: .5;
transform: scale(.92);
}
.row::after {
content: "";
clear: both;
display: table;
}
.heading h1 {
font-size: 150%;
font-family: Helvetica, arial, sans-serif;
font-weight: bold;
text-align: center;
color: purple;
}
.video-area video {
margin: 0 auto;
display: block;
}
.footer {
position: fixed;
width: 100%;
bottom: 0;
}
<!doctype html>
<html>
<head>
<title> Project One </title>
<link rel="stylesheet" href="C:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/main.css">
<link rel="stylesheet" href="C:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/lightbox.css">
<link rel="stylesheet" href="index.css">
</head>
<body>
<header>
<div class="header-section">
<div class="header-logo">
<h1> Superstar </h1>
</div>
<div class="header-right">
<p> Plot No.33,Mahalaxmi Nagar, Vizianagaram-535 002.<br>
email:saisankarmandala#gmail.com.
</p>
</div>
</div>
</header>
<nav>
<ul>
<li>Home</li>
<li>Products</li>
<li>Blog</li>
<li>Contact Us</li>
</ul>
</nav>
<div class="container"></div>
<div class="hero-text">
<h1> I am Creative </h1>
</div>
<div class="row">
<h1> My Gallery </h1>
</div>
<div class="col col-md-8-pushdown-sm">
<div class="column">
<div class="thumbnails">
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb4.jpg" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb4a.jpg" alt="thumb" width="200" height="200"></a>
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb5.png" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb5a.png" alt="thumb" width="200" height="200"></a>
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb6.jpg" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb6a.jpg" alt="thumb" width="200" height="200"></a>
</div>
</div>
<div class="column">
<div class="thumbnails">
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb4.jpg" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb4a.jpg" alt="thumb" width="200" height="200"></a>
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb5.png" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb5a.png" alt="thumb" width="200" height="200"></a>
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb6.jpg" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb6a.jpg" alt="thumb" width="200" height="200"></a>
</div>
</div>
<div class="column">
<div class="thumbnails">
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb7.jpg" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb7a.jpg" alt="thumb" width="200" height="200"></a>
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb8.jpg" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb8a.jpg" alt="thumb" width="200" height="200"></a>
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb9.jpg" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb9a.jpg" alt="thumb" width="200" height="200"></a>
</div>
</div>
<div class="column">
<div class="thumbnails">
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb10.jpeg" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb10a.jpeg" alt="thumb" width="200" height="200"></a>
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb11.jpg" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb11a.jpg" alt="thumb" width="200" height="200"></a>
<a href="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb12.png" data-lightbox="gallery">
<img src="c:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/thumb12a.png" alt="thumb" width="200" height="200"></a>
</div>
</div>
</div>
<div class="row">
<div class="heading">
<h1> My Videos </h1>
</div>
</div>
<div class="column">
<div class="video-area">
<video height="150" width="200" controls>
<source src="C:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/vids/vid1.mp4" type="video/mp4" >
<source src="C:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/vids/vid2.mp4" type="video/mp4">
</video>
</div>
</div>
<div class="clearfix"></div>
<footer>
<p>&copy 2021, All rights reserved </p>
</footer>
<script type="text/javascript" src="C:/Users/saisa/OneDrive/Desktop/HTML TUTORIAL/p1/lightbox-plus-jquery.js"></script>
</body>
</html>

Change submenu (dropdown) direction from vertical to horizontal

Right now I have dropdown menus in a vertical direction like this:
I want to change the dropdown menu so that they appear in a horizontal direction, preferred centered of a menu item:
I am using divs (.dropdown, .dropdown-content)
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 16px;
outline: none;
background-image: linear-gradient(#F1F1F1, #E5E5E5);
font-family: inherit;
margin: 0;
width: 150px;
height: 160px;
border: 1px solid white;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}
.dropdown-content {
display: none;
position: absolute;
background-image: linear-gradient(#F1F1F1, #E5E5E5);
border: 1px solid white;
width: 150px;
height: auto;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
padding-bottom: 10px;
}
How can I change the direction and alignment?
<div class="dropdown">
<button class="dropbtn" data-showdiv="CO">
<div class="titleh2">Title</div>
<img class="orga" src="picture.png">
<div class="titleh1">Name</div>
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<a href="#" class="firstImage">
<img class="orga" src="\untitled.png" />
</a>
<div class="titleh2">Title</div><br>
<div class="titleh3">Name</div>
<hr class="horizontal">
<a href="#">
<img class="orga" src="\untitled.png">
</a>
<div class="titleh2">Title</div><br>
<div class="titleh3">Name</div>
<hr class="horizontal">
<a href="#">
<img class="orga" src="\untitled.png">
</a>
<div class="titleh2">Title</div><br>
<div class="titleh3">Name</div>
</div>
</div>
You can use FlexBox to achieve the wanted result. Keep in mind, that flexbox is farily new and not supported in older browsers.
What I did:
Change the display-setting of dropdown-content to display:flex; and added flex-direction: row to align them horizontally.
Then I wrapped all dropdown-elements with a div to give every element of the dropdown some styling in case of need.
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 16px;
outline: none;
background-image: linear-gradient(#F1F1F1, #E5E5E5);
font-family: inherit;
margin: 0;
width: 150px;
height: 160px;
border: 1px solid white;
border-radius: 5px;
}
.dropdown-content {
/*display: none; //Change this to display flex, with the flex-direction to align the items horizontally*/
display: flex;
flex-direction: row;
position: absolute;
background-image: linear-gradient(#F1F1F1, #E5E5E5);
border: 1px solid white;
height: auto;
border-radius: 5px;
padding-bottom: 10px;
}
.dropdown-content-element{
margin: 2px 5px;
padding: 5px;
}
<div class="dropdown">
<button class="dropbtn" data-showdiv="CO">
<div class="titleh2">Title</div>
<img class="orga" src="picture.png">
<div class="titleh1">Name</div>
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<div class="dropdown-content-element">
<a href="#" class="firstImage">
<img class="orga" src="\untitled.png" />
</a>
<div class="titleh2">Title</div>
<div class="titleh3">Name</div>
</div>
<div class="dropdown-content-element">
<a href="#">
<img class="orga" src="\untitled.png">
</a>
<div class="titleh2">Title</div>
<div class="titleh3">Name</div>
</div>
<div class="dropdown-content-element">
<a href="#">
<img class="orga" src="\untitled.png">
</a>
<div class="titleh2">Title</div>
<div class="titleh3">Name</div>
</div>
</div>
</div>
And here is a little cheatsheet to get you started with FlexBox.
EDIT:
This works, but without being centered on the selected supermenu-item. But you'll achieve that yourself, I trust in you!
Oh and by the way: You can sum up your border-radius rules with border-radius: 5px; if all are the same. Saves some space and maintains better readability.
EDIT 2:
Here is an example of using ul and li to achieve a similar result. This method was suggested by #Moose in one of his comments.
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 16px;
outline: none;
background-image: linear-gradient(#F1F1F1, #E5E5E5);
font-family: inherit;
margin: 0;
width: 150px;
height: 160px;
border: 1px solid white;
border-radius: 5px;
}
.dropdown-content {
/*display: none;*/
position: absolute;
background-image: linear-gradient(#F1F1F1, #E5E5E5);
border: 1px solid white;
height: auto;
border-radius: 5px;
padding-bottom: 10px;
}
.dropdown-list {
list-style: none;
}
.dropdown-list>li {
display: inline-block;
}
<div class="dropdown">
<button class="dropbtn" data-showdiv="CO">
<div class="titleh2">Title</div>
<img class="orga" src="picture.png">
<div class="titleh1">Name</div>
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<ul class="dropdown-list">
<li>
<a href="#" class="firstImage">
<img class="orga" src="\untitled.png" />
</a>
<div class="titleh2">Title</div>
<div class="titleh3">Name</div>
</li>
<li>
<a href="#">
<img class="orga" src="\untitled.png">
</a>
<div class="titleh2">Title</div>
<div class="titleh3">Name</div>
</li>
<li>
<a href="#">
<img class="orga" src="\untitled.png">
</a>
<div class="titleh2">Title</div>
<div class="titleh3">Name</div>
</li>
</ul>
</div>
</div>

Centering a div containing multiple images inside another div

I am having problems trying to center a div containing four contact images inside of another div. The following is my HTML code for it:
<div id="contact" class="infoSection">
<div id="centeredConctact">
<!--<img class="contactImg" src="images/email.png" alt="Email"></img>-->
<img class="contactImg" src="images/facebook.png" alt="Facebook"></img>
<img class="contactImg" src="images/instagram.png" alt="Instagram"></img>
<img class="contactImg" src="images/twitter.png" alt="Twitter"></img>
<img class="contactImg" src="images/snapchat.png" alt="Snapchat"></img>
</div>
</div>
And the CSS is
div#contact {
border: 1px solid red;
}
div#centeredConctact {
margin: 0 auto;
width: 50%;
}
img.contactImg {
width:50px;
height:50px;
display: inline-block;
margin: 0 auto;
}
div.infoSection {
margin-top: 15px;
padding: 0;
width: 60%;
min-width: 600px;
}
What could I do to fix this? Thank you.
Let me know if this is not what you are trying to achieve. Your question was a little vague but this is what I took from it.
div#contact {
border: 1px solid red;
width: 100%;
}
div#centeredConctact {
text-align: center;
}
img.contactImg {
width: 50px;
height: 50px;
display: inline-block;
margin:4px 1px 1px;
}
a.contactImg {
text-decoration:none;
}
div.infoSection {
margin-top: 15px;
padding: 0;
}
<div id="contact" class="infoSection">
<div id="centeredConctact">
<!--<img class="contactImg" src="images/email.png" alt="Email">-->
<img class="contactImg" src="http://placehold.it/50x50/333333/dddddd&text=F" alt="Facebook">
<img class="contactImg" src="http://placehold.it/50x50/333333/dddddd&text=I" alt="Instagram">
<img class="contactImg" src="http://placehold.it/50x50/333333/dddddd&text=T" alt="Twitter">
<img class="contactImg" src="http://placehold.it/50x50/333333/dddddd&text=S" alt="Snapchat">
</div>
</div>
The div is already centered.
Center the images (respectively the links) with text-algin: center.
div#contact {
border: 1px solid red;
}
div#centeredConctact {
margin: 0 auto;
width: 50%;
border: 1px solid;
text-align: center;
}
img.contactImg {
width: 50px;
height: 50px;
display: inline-block;
}
div.infoSection {
margin-top: 15px;
padding: 0;
width: 60%;
min-width: 600px;
}
<div id="contact" class="infoSection">
<div id="centeredConctact">
<!--<img class="contactImg" src="images/email.png" alt="Email"></img>-->
<a href="" rel="noopener noreferrer"><img class="contactImg" src="images/facebook.png" alt="Facebook">
</a>
<a href="" rel="noopener noreferrer"><img class="contactImg" src="images/instagram.png" alt="Instagram">
</a>
<a href="" rel="noopener noreferrer"><img class="contactImg" src="images/twitter.png" alt="Twitter">
</a>
<a href="" rel="noopener noreferrer"><img class="contactImg" src="images/snapchat.png" alt="Snapchat">
</a>
</div>
</div>
Try using flaxbox layout like this:
div#contact {
border: 1px solid red;
display: flex;
justify-content: center
}
img.contactImg {
width: 50px;
height: 50px;
margin: 3px 1px 0;
}
div.infoSection {
margin-top: 15px;
padding: 0;
width: 60%;
min-width: 600px;
}
<div id="contact" class="infoSection">
<div id="centeredConctact">
<!--<img class="contactImg" src="images/email.png" alt="Email"></img>-->
<img class="contactImg" src="http://placehold.it/50x50" alt="Facebook"></img>
<img class="contactImg" src="http://placehold.it/50x50" alt="Instagram"></img>
<img class="contactImg" src="http://placehold.it/50x50" alt="Twitter"></img>
<img class="contactImg" src="http://placehold.it/50x50" alt="Snapchat"></img>
</div>
</div>

Gallery (picture shower)

I'm making a Gallery page on my web site (project) and I've put <a target="_blank"but I don't like It :P. So I've remembered on some sites there is like pop-up window with picture and when you click on left or right side of the picture it slides to the next or previous picture. Best way to explain it is showing you LINK. Thanks in advance.
EDIT Click on those pictures under the Skins!!!!
body {
background-image: url("https://s-media-cache-ak0.pinimg.com/originals/e4/98/1a/e4981a3dd4aa2fa6f0bc84cde9087c7a.jpg");
background-attachment: fixed;
box-sizing: border-box;
margin-left: 20px;
margin-right: 20px;
margin-top: 0px;
margin-bottom: 0px;
border-top-left-radius: 25px;
border-top-right-radius: 25px;
border-right: solid rgb(200, 101, 103);
border-left: solid rgb(200, 101, 103);
border-bottom-left-radius: 25px;
border-bottom-right-radius: 25px;
}
#header {
height: 50px;
box-sizing: border-box;
width: auto;
}
#navigacija {
right: 20px;
left: 20px;
height: 50px;
overflow: hidden;
text-align: right;
background-color: #089DE3;
z-index: 9999;
box-sizing: border-box;
border-radius: 25px;
position: fixed;
border-top: solid rgb(200, 101, 103);
border-bottom: solid rgb(200, 101, 103);
}
.navitem {
background: #089DE3;
color: white;
line-height: 50px;
font-size: 30px;
font-family: "Fjalla One";
display: inline-block;
padding-left: 50px;
padding-right: 50px;
box-sizing: border-box;
}
.home:hover {
background: #00C5CD;
box-sizing: border-box;
}
.gallery:hover {
background: #00C5CD;
box-sizing: border-box;
}
.contact:hover {
box-sizing: border-box;
background: #00C5CD;
}
.info:hover {
box-sizing: border-box;
background: #00C5CD;
}
.active {
background-color: #00C5CD;
box-sizing: border-box;
}
h1 {
text-align: center;
font-family: "Jockey One";
font-size: 100px;
color: white;
}
div.galerija {
margin-left: 10px;
margin-right:32px;
margin-bottom:10px;
border: 1px solid rgb(200, 101, 103);
float: left;
width: 300px;
}
div.galerija:hover {
border: 1px solid white;
}
div.desc {
padding: 10px;
text-align: center;
color: black;
background-color: white;
font-size: 20px;
font-family:"Jockey One";
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta name="generator" content="HTML Tidy for Linux (vers 25 March 2009), see www.w3.org" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>GALLERY</title>
<link rel="stylesheet" href="Gallery.css" type="text/css" />
<link href="https://fonts.googleapis.com/css?family=Jockey+One" rel="stylesheet" type="text/css" />
<link href="https://fonts.googleapis.com/css?family=Allerta+Stencil" rel="stylesheet" type="text/css" />
<link href="https://fonts.googleapis.com/css?family=Fjalla+One" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="header">
<div id="navigacija">
<a href="Home.html">
<div class="navitem home"><strong>HOME</strong></div>
</a>
<a href="Gallery.html">
<div class="navitem gallery active"><strong>GALLERY</strong></div></a>
<div class="navitem contact"><strong>CONTACT</strong></div>
<div class="navitem info"><strong>INFO</strong></div>
</div>
</div>
<h1><strong>GALLERY</strong></h1>
<div class="galerija">
<a target="_blank" href="http://www.downvids.net/video/bestimages/img-aatrox-the-darkin-blade-196.jpg">
<img src="http://www.downvids.net/video/bestimages/img-aatrox-the-darkin-blade-196.jpg" alt="Aatrox" width="300" height="200">
</a>
<div class="desc">Aatrox, the Darkin Blade</div>
</div>
<div class="galerija">
<a target="_blank" href="https://i.ytimg.com/vi/xE4e_cLMgjU/maxresdefault.jpg">
<img src="https://i.ytimg.com/vi/xE4e_cLMgjU/maxresdefault.jpg" alt="Ahri" width="300" height="200"></a>
<div class="desc">Ahri, the Nine-Tailed Fox</div>
</div>
<div class="galerija">
<a target="_blank" href= "https://cdn.tryhardgopro.com/static/ddragon/cdn/img/champion/splash/Akali_0.jpg ">
<img src="https://cdn.tryhardgopro.com/static/ddragon/cdn/img/champion/splash/Akali_0.jpg " alt="Akali" width="300" height="200"></a>
<div class="desc">Akali, the Fist of Shadow</div>
</div>
<div class="galerija">
<a target="_blank" href="http://ddragon.leagueoflegends.com/cdn/img/champion/splash/Alistar_0.jpg">
<img src="http://ddragon.leagueoflegends.com/cdn/img/champion/splash/Alistar_0.jpg" alt="Alistar" width="300" height="200"></a>
<div class="desc">Alistar, the Minotaur</div>
</div>
<div class="galerija">
<a target="_blank" href="https://cdn.tryhardgopro.com/static/ddragon/cdn/img/champion/splash/Amumu_0.jpg">
<img src="https://cdn.tryhardgopro.com/static/ddragon/cdn/img/champion/splash/Amumu_0.jpg" alt="Amumu" width="300" height="200"></a>
<div class="desc">Amumu, the Sad Mummy</div>
</div>
<div class="galerija">
<a target="_blank" href="http://static.lolskill.net/img/skins/1215/anivia_0.jpg">
<img src="http://static.lolskill.net/img/skins/1215/anivia_0.jpg " alt="Anivia" width="300" height="200"></a>
<div class="desc">Anivia, the Cryophoenix</div>
</div>
<div class="galerija">
<a target="_blank" href="http://media-titanium.cursecdn.com/loldiffs/AirClientDiff_1_28_2013_2_28_PM/images/Annie_Splash_0.jpg">
<img src="http://media-titanium.cursecdn.com/loldiffs/AirClientDiff_1_28_2013_2_28_PM/images/Annie_Splash_0.jpg" alt="Annie" width="300" height="200"></a>
<div class="desc">Annie, the Dark Child</div>
</div>
<div class="galerija">
<a target="_blank" href="http://images2.wikia.nocookie.net/__cb20101005190542/leagueoflegends/images/c/c0/Ashe_OriginalSkin.jpg">
<img src="http://images2.wikia.nocookie.net/__cb20101005190542/leagueoflegends/images/c/c0/Ashe_OriginalSkin.jpg" alt="Ashe" width="300" height="200"></a>
<div class="desc">Ashe, the Frost Archer</div>
</div>
<div class="galerija">
<a target="_blank" href="http://s.lolstatic.com/site/mount-targon/079694fdf251b5e7de788d9ab439d401d31ae160/img/champions/aurelion-sol/aurelion-sol-splash-fallback.jpg">
<img src="http://s.lolstatic.com/site/mount-targon/079694fdf251b5e7de788d9ab439d401d31ae160/img/champions/aurelion-sol/aurelion-sol-splash-fallback.jpg" alt="Aurelion Sol" width="300" height="200"></a>
<div class="desc">Aurelion Sol, the Star Forger</div>
</div>
<div class="galerija">
<a target="_blank" href="https://assets.vg247.com/current//2015/09/league_of_legnds_azir.jpg">
<img src="https://assets.vg247.com/current//2015/09/league_of_legnds_azir.jpg" alt="Azir" width="300" height="200"></a>
<div class="desc">Azir, the Emperor of the Sands</div>
</div>
<div class="galerija">
<a target="_blank" href="http://news.cdn.leagueoflegends.com/public/images/pages/2015/breveal/img/Bard_Splash_WP.jpg">
<img src="http://news.cdn.leagueoflegends.com/public/images/pages/2015/breveal/img/Bard_Splash_WP.jpg" alt="Bard" width="300" height="200"></a>
<div class="desc">Bard, the Wandering Caretaker</div>
</div>
<div class="galerija">
<a target="_blank" href="http://static.lolskill.net/img/skins/1215/blitzcrank_0.jpg">
<img src="http://static.lolskill.net/img/skins/1215/blitzcrank_0.jpg" alt="Blitzcrank" width="300" height="200"></a>
<div class="desc">Blitzcrank, the Great Steam Golem</div>
</div>
<div class="galerija">
<a target="_blank" href="http://ddragon.leagueoflegends.com/cdn/img/champion/splash/Brand_0.jpg">
<img src="http://ddragon.leagueoflegends.com/cdn/img/champion/splash/Brand_0.jpg" alt="Brand" width="300" height="200"></a>
<div class="desc">Brand, the Burning Vengeance</div>
</div>
<div class="galerija">
<a target="_blank" href="http://na.leagueoflegends.com/sites/default/files/styles/scale_xlarge/public/upload/b-splash.jpg?itok=vJzNVWjn">
<img src="http://na.leagueoflegends.com/sites/default/files/styles/scale_xlarge/public/upload/b-splash.jpg?itok=vJzNVWjn" alt="Braum" width="300" height="200"></a>
<div class="desc">Braum, the Heart of the Freljord</div>
</div>
<div class="galerija">
<a target="_blank" href="https://img.clipartfox.com/5633c6d56bed03beb9292dd8c7f26199_-league-of-legends-and-caitlyn-league-of-legends-clipart_1215-717.jpeg">
<img src="https://img.clipartfox.com/5633c6d56bed03beb9292dd8c7f26199_-league-of-legends-and-caitlyn-league-of-legends-clipart_1215-717.jpeg" alt="Caitlyn" width="300" height="200"></a>
<div class="desc">Caitlyn, the Sheriff of Piltover</div>
</div>
<div class="galerija">
<a target="_blank" href="http://ddragon.leagueoflegends.com/cdn/img/champion/splash/Camille_0.jpg">
<img src="http://ddragon.leagueoflegends.com/cdn/img/champion/splash/Camille_0.jpg" alt="Camille" width="300" height="200"></a>
<div class="desc">Camille, the Steel Shadow</div>
</div>
</body>
</html>
You need to search for a lightbox gallery JavaScript plugin.There's a lot of them out there.
The one used on the example you gave is named Colorbox. Here you'll find more information about it: http://www.jacklmoore.com/colorbox/
Colorbox is based on jQuery library, so you'll need to use booth.
If you only need the gallery and you dont want to use jQuery you can give a try to jsLightbox http://jslightbox.felixhagspiel.de/ which is a pure JavaScript based gallery.
Here is a crude looking but functional example of a image gallery that pops up in a modal:
var images = $('.slideshow img');
var numImages = $('.slideshow img').length - 1;
var modalButton = $('.modal-button');
var prev = $('.prev');
var next = $('.next');
var num = 0;
modalButton.on('click', function() {
$('.slideshow').toggleClass('active');
})
prev.on('click', function() {
images.removeClass('active');
num--;
if (num < 0) {
num = numImages;
}
images.eq(num).addClass('active');
});
next.on('click', function() {
images.removeClass('active');
num++;
if (num > numImages) {
num = 0;
}
images.eq(num).addClass('active');
});
* {
box-sizing: border-box;
}
.content {
width: 100%;
max-width: 1024px;
min-height: 100vh;
margin: 0 auto;
position: relative;
text-align: center;
background-color: gray;
}
.modal-button {
padding: 10px;
position: relative;
border: 2px solid green;
background-color: #fff;
z-index: 3;
}
.modal-button:hover {
cursor: pointer;
}
.slideshow {
display: none;
flex-direction: column;
justify-content: center;
margin: auto;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: rgba(0, 0, 0, 0.7);
z-index: 2;
}
.slideshow.active {
display: flex;
}
.image-container {
margin: 0 auto;
}
.image-container img {
display: none;
}
.image-container img.active {
display: inline;
}
.slideshow-controls {
width: 350px;
margin: 0 auto;
padding: 20px;
position: absolute;
left: 0;
right: 0;
bottom: 0;
text-align: center;
background-color: tomato;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<section class="content">
<a class="modal-button">Click here to toggle slideshow</a>
<section class="slideshow">
<div class="image-container">
<img class="active" src="http://placehold.it/350x350/000/bae">
<img src="http://placehold.it/250x150/fff/58b">
<img src="http://placehold.it/350x200/333/aeb">
<img src="http://placehold.it/400x150/666/33c">
</div>
<div class="slideshow-controls">
<button class="prev">Prev</button>
<button class="next">Next</button>
</div>
</section>
</section>

Gallery display horizontally with images with the same size

I'm working on HTML and CSS and I'm having a hard time aligning the images horizontally instead of vertically.
I tried displaying them inline-block and inline none of them works. And I also want my images to have the same sizes.
Here's my html code:
#gallery {
width: 500px;
overflow: hidden;
position: relative;
z-index: 1;
margin: 100px auto;
display: inline;
}
#gallery img {
width: 50%;
height: auto;
border: 5px solid #FFFFFF;
margin: 10px;
box-sizing: border-box;
margin: 0 auto;
padding: 0;
}
<div id="gallery">
<img src="images/gallery1.png">
<img src="images/gallery2.png">
<img src="images/gallery3.png">
<img src="images/gallery4.png">
<img src="images/gallery5.png">
<img src="images/gallery6.png">
<script src="lightbox2-master/dist/js/lightbox-plus-jquery.js"></script>
</div>
Try this:
div.gallery {
margin: 5px;
border: 1px solid #ccc;
float: left;
width: 180px;
}
div.gallery:hover {
border: 1px solid #777;
}
div.gallery img {
width: 100%;
height: auto;
}
div.desc {
padding: 15px;
text-align: center;
}
<div class="gallery">
<a href="images/gallery1.png" data-lightbox="image-1" data-title="Ian and Vee">
<img src="images/gallery1.png" width="600" height="400">
</a>
</div>
<div class="gallery">
<a href="images/gallery1.png" data-lightbox="image-1" data-title="Ian and Vee">
<img src="images/gallery1.png" width="600" height="400">
</a>
</div>
<div class="gallery">
<a href="images/gallery1.png" data-lightbox="image-1" data-title="Ian and Vee">
<img src="images/gallery1.png" width="600" height="400">
</a>
</div>
<div class="gallery">
<a href="images/gallery1.png" data-lightbox="image-1" data-title="Ian and Vee">
<img src="images/gallery1.png" width="600" height="400">
</a>
</div>
<div class="gallery">
<a href="images/gallery1.png" data-lightbox="image-1" data-title="Ian and Vee">
<img src="images/gallery1.png" width="600" height="400">
</a>
</div>
<div class="gallery">
<a href="images/gallery1.png" data-lightbox="image-1" data-title="Ian and Vee">
<img src="images/gallery1.png" width="600" height="400">
</a>
</div>
Simpler answer. Add a float to your image.
#gallery {
width: 500px;
overflow: hidden;
position: relative;
z-index: 1;
margin: 100px auto;
display: inline;
}
#gallery img {
float: left;
width: 50%;
height: auto;
border: 5px solid #FFFFFF;
margin: 10px;
box-sizing: border-box;
margin: 0 auto;
padding: 0;
}