Bootstrap Directory Grid - html

Good evening,
I'm trying to write a grid that would serve as a directory of employees. It would feature a thumbnail on the left, and name and title on the right. I'd like the name and title to be vertically aligned in the middle. Aside from the vertical alignment issue, I'm also having a problem that when the name or title get too long, it wraps the entire span underneath the image.
Here is the CSS and markup (using the latest Bootstrap). Could anyone lend a hand?
<!-- Begin People Listing -->
<style type="text/css">
ul.people-list {
margin: 0;
padding: 0;
}
ul.people-list li {
list-style: none;
padding: 0;
}
ul.people-list li a {
display: block;
border: 2px solid #eee;
margin: 5px;
padding: 30px;
min-height: 125px;
}
ul.people-list li a:hover {
background: #eee;
}
ul.people-list span {
display: block;
float: left;
}
ul.people-list span.portrait {
border: 0px solid red;
margin-right: 20px;
}
ul.people-list span.name {
border: 0px solid blue;
}
ul.people-list span.name h4 {
margin: 0;
color: #00654e;
}
ul.people-list span.name h5 {
color: #000;
margin: 0;
}
</style>
<ul class="row people-list">
<li class="col-xs-12 col-sm-6 col-md-4">
<a class="clearfix" href="#">
<span class="portrait">
<img src="http://lorempixel.com/100/100/people" class="img-circle">
</span>
<span class="name">
<h4>Dr. Someone somebody with a really really long name?</h4>
<h5>Criminal Justice Administration</h5>
</span>
</a>
</li>
<li class="col-xs-12 col-sm-6 col-md-4">
<a class="clearfix" href="#">
<span class="portrait">
<img src="http://lorempixel.com/100/100/people" class="img-circle">
</span>
<span class="name">
<h4>Dr. Catherina Abbott</h4>
<h5>Assistant Professor of Mathematics</h5>
</span>
</a>
</li>
<li class="col-xs-12 col-sm-6 col-md-4">
<a class="clearfix" href="#">
<span class="portrait">
<img src="http://lorempixel.com/100/100/people" class="img-circle">
</span>
<span class="name">
<h4>Catherina Abbott</h4>
<h5>Mathematics</h5>
</span>
</a>
</li>
<li class="col-xs-12 col-sm-6 col-md-4">
<a class="clearfix" href="#">
<span class="portrait">
<img src="http://lorempixel.com/100/100/people" class="img-circle">
</span>
<span class="name">
<h4>Catherina Abbott</h4>
<h5>Mathematics</h5>
</span>
</a>
</li>
<li class="col-xs-12 col-sm-6 col-md-4">
<a class="clearfix" href="#">
<span class="portrait">
<img src="http://lorempixel.com/100/100/people" class="img-circle">
</span>
<span class="name">
<h4>Catherina Abbott</h4>
<h5>Mathematics</h5>
</span>
</a>
</li>
</ul>
<!-- End People Listing -->

This can be simplified a great deal (I think) by placing your people-list class inside of a column, then add your styling from there.
*If this needs built using a list format that can be swapped out depending on how you ultimately need it structured.
Grid Example
.people-list {
display: block;
vertical-align: middle;
padding: 10px;
margin: 10px auto;
border: 2px solid #eee;
}
a.people-list:hover {
background-color: #eee;
text-decoration: none;
}
.portrait,
.name {
display: table-cell;
vertical-align: middle;
padding: 10px;
}
.name h4 {
color: #00654e;
}
.name h5 {
color: #000;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-4">
<a class="people-list" href="#">
<span class="portrait">
<img src="http://lorempixel.com/100/100/people" class="img-circle">
</span>
<span class="name">
<h4>Dr. Someone somebody with a really really long name?</h4>
<h5>Criminal Justice Administration</h5>
</span>
</a>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<a class="people-list" href="#">
<span class="portrait">
<img src="http://lorempixel.com/100/100/people" class="img-circle">
</span>
<span class="name">
<h4>Dr. Someone somebody with a really really long name?</h4>
<h5>Criminal Justice Administration</h5>
</span>
</a>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<a class="people-list" href="#">
<span class="portrait">
<img src="http://lorempixel.com/100/100/people" class="img-circle">
</span>
<span class="name">
<h4>Dr. Someone somebody with a really really long name?</h4>
<h5>Criminal Justice Administration</h5>
</span>
</a>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<a class="people-list" href="#">
<span class="portrait">
<img src="http://lorempixel.com/100/100/people" class="img-circle">
</span>
<span class="name">
<h4>Dr. Someone somebody with a really really long name?</h4>
<h5>Criminal Justice Administration</h5>
</span>
</a>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<a class="people-list" href="#">
<span class="portrait">
<img src="http://lorempixel.com/100/100/people" class="img-circle">
</span>
<span class="name">
<h4>Dr. Someone somebody with a really really long name?</h4>
<h5>Criminal Justice Administration</h5>
</span>
</a>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<a class="people-list" href="#">
<span class="portrait">
<img src="http://lorempixel.com/100/100/people" class="img-circle">
</span>
<span class="name">
<h4>Dr. Someone somebody with a really really long name?</h4>
<h5>Criminal Justice Administration</h5>
</span>
</a>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<a class="people-list" href="#">
<span class="portrait">
<img src="http://lorempixel.com/100/100/people" class="img-circle">
</span>
<span class="name">
<h4>Dr. Someone somebody with a really really long name?</h4>
<h5>Criminal Justice Administration</h5>
</span>
</a>
</div>
<div class="col-xs-12 col-sm-6 col-md-4">
<a class="people-list" href="#">
<span class="portrait">
<img src="http://lorempixel.com/100/100/people" class="img-circle">
</span>
<span class="name">
<h4>Dr. Someone somebody with a really really long name?</h4>
<h5>Criminal Justice Administration</h5>
</span>
</a>
</div>
</div>
</div>
List Example
.people-list {
display: block;
vertical-align: middle;
padding: 10px;
margin: 10px auto;
border: 2px solid #eee;
}
a.people-list:hover {
background-color: #eee;
text-decoration: none;
}
.portrait,
.name {
display: table-cell;
vertical-align: middle;
padding: 10px;
}
.name h4 {
color: #00654e;
}
.name h5 {
color: #000;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<ul class="row list-unstyled">
<li class="col-xs-12 col-sm-6 col-md-4">
<a class="people-list" href="#">
<span class="portrait">
<img src="http://lorempixel.com/100/100/people" class="img-circle">
</span>
<span class="name">
<h4>Dr. Someone somebody with a really really long name?</h4>
<h5>Criminal Justice Administration</h5>
</span>
</a>
</li>
<li class="col-xs-12 col-sm-6 col-md-4">
<a class="people-list" href="#">
<span class="portrait">
<img src="http://lorempixel.com/100/100/people" class="img-circle">
</span>
<span class="name">
<h4>Dr. Someone somebody with a really really long name?</h4>
<h5>Criminal Justice Administration</h5>
</span>
</a>
</li>
<li class="col-xs-12 col-sm-6 col-md-4">
<a class="people-list" href="#">
<span class="portrait">
<img src="http://lorempixel.com/100/100/people" class="img-circle">
</span>
<span class="name">
<h4>Dr. Someone somebody with a really really long name?</h4>
<h5>Criminal Justice Administration</h5>
</span>
</a>
</li>
<li class="col-xs-12 col-sm-6 col-md-4">
<a class="people-list" href="#">
<span class="portrait">
<img src="http://lorempixel.com/100/100/people" class="img-circle">
</span>
<span class="name">
<h4>Dr. Someone somebody with a really really long name?</h4>
<h5>Criminal Justice Administration</h5>
</span>
</a>
</li>
<li class="col-xs-12 col-sm-6 col-md-4">
<a class="people-list" href="#">
<span class="portrait">
<img src="http://lorempixel.com/100/100/people" class="img-circle">
</span>
<span class="name">
<h4>Dr. Someone somebody with a really really long name?</h4>
<h5>Criminal Justice Administration</h5>
</span>
</a>
</li>
<li class="col-xs-12 col-sm-6 col-md-4">
<a class="people-list" href="#">
<span class="portrait">
<img src="http://lorempixel.com/100/100/people" class="img-circle">
</span>
<span class="name">
<h4>Dr. Someone somebody with a really really long name?</h4>
<h5>Criminal Justice Administration</h5>
</span>
</a>
</li>
<li class="col-xs-12 col-sm-6 col-md-4">
<a class="people-list" href="#">
<span class="portrait">
<img src="http://lorempixel.com/100/100/people" class="img-circle">
</span>
<span class="name">
<h4>Dr. Someone somebody with a really really long name?</h4>
<h5>Criminal Justice Administration</h5>
</span>
</a>
</li>
<li class="col-xs-12 col-sm-6 col-md-4">
<a class="people-list" href="#">
<span class="portrait">
<img src="http://lorempixel.com/100/100/people" class="img-circle">
</span>
<span class="name">
<h4>Dr. Someone somebody with a really really long name?</h4>
<h5>Criminal Justice Administration</h5>
</span>
</a>
</li>
</ul>
</div>

I did some modifications to your code, deleting some heights and unnecessary classes to achieve your goal.
Take a look at the plunkr. Hope it helps!
/* Styles go here */
ul.people-list {
margin: 0;
padding: 0;
}
ul.people-list li {
list-style: none;
padding: 0;
}
ul.people-list li a {
display: block;
border: 2px solid #eee;
margin: 5px;
padding: 30px;
}
ul.people-list li a:hover {
background: #eee;
}
ul.people-list span {
display: block;
float: left;
}
ul.people-list span.portrait {
border: 0px solid red;
}
ul.people-list span.portrait img{
width:100%;
}
ul.people-list span.name {
border: 0px solid blue;
}
ul.people-list span.name h4 {
margin: 0 0 10px 0;
color: #00654e;
}
ul.people-list span.name h5 {
color: #000;
margin: 10px 0 0 0;
}
<!DOCTYPE html>
<html>
<head>
<link data-require="bootstrap#*" data-semver="3.3.5" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<link data-require="bootstrap#*" data-semver="3.3.5" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootswatch/3.3.5/cosmo/bootstrap.min.css" />
<link data-require="bootstrap#*" data-semver="3.3.5" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" />
<script data-require="bootstrap#*" data-semver="3.3.5" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body>
<ul class="row people-list">
<li class="col-xs-12 col-sm-6 col-md-4">
<a href="#">
<div class="row">
<div class="col-xs-3 col-sm-4 col-md-4">
<span class="portrait">
<img src="http://lorempixel.com/500/500/people" class="img-circle" />
</span>
</div>
<div class="col-xs-9 col-sm-8 col-md-8">
<span class="name">
<h4>Dr. Someone somebody with a really really long name?</h4>
<h5>Criminal Justice Administration</h5>
</span>
</div>
</div>
</a>
</li>
</ul>
</body>
</html>

Related

Anchor tag goes to the wrong section of a web page

Here's an actual video recording of what the problem is (I'm not trying to advertise in any way): https://www.youtube.com/watch?v=7b38cQ0VGWI
So I'm creating a website just for practice's sake, and everything was going smoothly until I ran into this problem. I have 2 <nav> menus, where the top main nav bar leads one to another page, while the 2nd nav bar leads one to a certain section within the same page. But I'm having problems with the 2nd nav bar. So below is the html I'm using:
<nav class="navbar">
<div class="container">
<ul>
<li>Drama</li>
<li>Comedy</li>
<li>Romance</li>
<li>Action</li>
</ul>
</div>
</nav>
After this is a series of movie picture lists but I'm only going input 2 below as an example:
<div class="grid-picture">
<!--First row of movies-->
<div id="action">
<div class="movies">
<a href="https://www.imdb.com/title/tt2911666/" target="_blank">
<img src="https://images-na.ssl-images-amazon.com/images/I/91atCmxi6hL._UR1200,1600_RI_.jpg">
<h3>John Wick</h3>
<p>Action, Crime, Triller</p>
</a>
</div>
</div>
<br>
<!--1st row of romance movies-->
<div id="romance">
<div class="movies">
<a href="https://www.imdb.com/title/tt1638002/?ref_=nv_sr_srsg_0">
<img src="https://kbimages1-a.akamaihd.net/beb95aaa-36b7-444d-8557-0cb7efa8e898/1200/1200/False/love-rosie-1.jpg">
<h3>Love, Rosie</h3>
<p>Comedy, Romance</p>
</a>
</div>
</div>
</div>
As you can see, "John Wick" is within a div tag with an ID of "action", while "Love, Rosie" is within a div tag with an ID of "romance." Now, the "Action" link works fine; it directs the page exactly where the movies within the ID of "action" are. However, when I click the "Romance" link, it doesn't take me to the bottom of the website. Rather, it takes me to the same place as if I clicked the "Action" link.
So basically, the anchor tag isn't working for me even though I made sure to input href="#romance" and also made sure to wrap around the movie "Love, Rosie" within a div tag with an ID of "romance". External links work just fine, only that internal links aren't working as I assumed it would. I also quadruple checked if I had any unclosed div tags, but that wasn't the case.
All of the movies are in the same page.
Below is the CSS (sorry for the disorganization, still working on that):
body {
margin: 0;
line-height: 1.6em;
font-size: 16px;
font-family: sans-serif;
}
.container {
width: 80%;
margin: auto;
overflow:hidden;
}
nav {
margin: 0;
color: #E52EAE;
z-index: 1;
}
nav ul {
list-style: none;
padding: 0;
}
nav li {
display: inline;
}
nav a{
text-decoration: none;
color: white;
padding-right: 18px;
padding-bottom: 5px;
text-align: center;
float: right;
}
.navbar {
margin-right: 227px;
position: relative;
font-size: 30px;
color: #22D8E5;
}
.navbar a:visited {
color: #22D8E5;
}
.navbar a:hover {
color: red;
}
#showcase {
background-image:url('http://getwallpapers.com/wallpaper/full/c/4/8/1367231-beautiful-black-cool-background-1920x1200-for-windows-7.jpg');
background-position: center right;
background-color: black;
background-size: 850px;
background-position: left;
height: 300px;
text-align: center;
color: white;
}
.movies {
box-sizing: border-box;
width: 25%;
float: left;
padding: 1px;
}
.movies img {
height: 500px;
width: 100%;
}
a:link {
text-decoration: none;
color: black;
}
a:visited {
color: coral;
}
a:hover {
color: red;
}
And here's the whole html:
<!DOCTYPE html>
<html>
<head>
<title>My Video Library</title>
<link rel="stylesheet" type="text/css" href="movies.css">
</head>
<body>
<section id="showcase">
<nav id="main-nav">
<div class="container">
<ul>
<li>Etc</li>
<li>Animation</li>
<li>LaughTime</li>
<li>Movies</li>
<li>Home</li>
</ul>
</div>
</nav>
<div class="container">
<h1>Movie List</h1>
<nav class="navbar">
<div class="container">
<ul>
<li>Drama</li>
<li>Comedy</li>
<li>Romance</li>
<li>Action</li>
</ul>
</div>
</nav>
</div>
</section>
<div class="grid-picture">
<!--First row of movies-->
<div id="action">
<div class="movies">
<a href="https://www.imdb.com/title/tt2911666/" target="_blank">
<img src="https://images-na.ssl-images-amazon.com/images/I/91atCmxi6hL._UR1200,1600_RI_.jpg" alt="john wick">
<h3>John Wick</h3>
<p>Action, Crime, Triller</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt2802144/" target="_blank">
<img src="https://cdn.collider.com/wp-content/uploads/2015/02/kingsman-the-secret-service-final-poster.jpg">
<h3>Kingsmen</h3>
<p>Action, Adventure, Comedy</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt2381249/" target="_blank">
<img src="https://images-na.ssl-images-amazon.com/images/I/81wcVvqV8pL._RI_.jpg">
<h3>Mission Impossible: Rogue Nation</h3>
<p>Action, Adventure, Thriller</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt0468569/" target="_blank">
<img src="https://images-na.ssl-images-amazon.com/images/I/91KkWf50SoL._SL1500_.jpg">
<h3>The Dark Knight</h3>
<p>Action, Crime, Drama</p>
</a>
</div>
<br>
<!--2nd row of movies-->
<div class="movies">
<a href="https://www.imdb.com/title/tt1431045/" target="_blank">
<img src="https://pics.filmaffinity.com/Deadpool-834516798-large.jpg">
<h3>Deadpool</h3>
<p>Action, Adventure, Comedy</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt3315342/" target="_blank">
<img src="https://vignette.wikia.nocookie.net/xmenmovies/images/2/22/Logan-Poster-5.jpg/revision/latest?cb=20170131012906">
<h3>Logan</h3>
<p>Action, Drama, Sci-Fi</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt6806448/" target="_blank">
<img src="https://musicart.xboxlive.com/7/e9225100-0000-0000-0000-000000000002/504/image.jpg?w=1920&h=1080">
<h3>Fast & Furious: Hobbs & Shaw</h3>
<p>Action, Adventure</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt0371746/" target="_blank">
<img src="https://cdn.collider.com/wp-content/uploads/2015/04/iron-man-1-poster.jpg">
<h3>Iron Man</h3>
<p>Action, Adventure, Sci-Fi</p>
</a>
</div>
<br>
<!--3rd row of movies-->
<div class="movies">
<a href="https://www.imdb.com/title/tt3501632/" target="_blank">
<img src="https://m.media-amazon.com/images/M/MV5BMjMyNDkzMzI1OF5BMl5BanBnXkFtZTgwODcxODg5MjI#._V1_.jpg">
<h3>Thor: Ragnarok</h3>
<p>Action, Adventure, Comedy</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt1631867/" target="_blank">
<img src="http://collider.com/wp-content/uploads/edge-of-tomorrow-poster3.jpg">
<h3>Edge of Tomorrow</h3>
<p>Action, Sci-Fi</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt2024469/?ref_=nv_sr_srsg_0" target="_blank">
<img src="https://m.media-amazon.com/images/M/MV5BOTI3NzcxMjkzMl5BMl5BanBnXkFtZTgwMDY0NTQ0MDE#._V1_.jpg">
<h3>Non-Stop</h3>
<p>Action, Thriller, Mystery</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt0936501/?ref_=nv_sr_srsg_0" target="_blank">
<img src="https://images-na.ssl-images-amazon.com/images/I/91gANPtj-7L._SL1500_.jpg">
<h3>Taken</h3>
<p>Action, Thriller</p>
</a>
</div>
<br>
<!--4th row of movies-->
<div class="movies">
<a href="https://www.imdb.com/title/tt4154756/?ref_=nv_sr_srsg_3" target="_blank">
<img src="https://m.media-amazon.com/images/M/MV5BMjMxNjY2MDU1OV5BMl5BanBnXkFtZTgwNzY1MTUwNTM#._V1_.jpg">
<h3>Avengers: Infinity War</h3>
<p>Action, Adventure, Sci-Fi</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt4154796/?ref_=nv_sr_srsg_0" target="_blank">
<img src="https://m.media-amazon.com/images/M/MV5BMTc5MDE2ODcwNV5BMl5BanBnXkFtZTgwMzI2NzQ2NzM#._V1_.jpg">
<h3>Avengers: Endgame</h3>
<p>Action, Adventure, Drama</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt6146586/?ref_=nv_sr_srsg_0" target="_blank">
<img src="https://i.pinimg.com/originals/1b/03/a1/1b03a1a68c4616f8fb203d00a2849a9a.jpg">
<h3>John Wick 3: Chapter 3 - Parabellum</h3>
<p>Action, Crime, Thriller</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt1270797/?ref_=nv_sr_srsg_0">
<img src="https://images-na.ssl-images-amazon.com/images/I/91ZwG8Ytb3L._RI_.jpg">
<h3>Venom</h3>
<p>Action, Sci-Fi, Thriller</p>
</a>
</div>
<br>
<!--5th row of movies-->
<div class="movies">
<a href="https://www.imdb.com/title/tt2015381/?ref_=nv_sr_srsg_0">
<img src="https://m.media-amazon.com/images/M/MV5BMTAwMjU5OTgxNjZeQTJeQWpwZ15BbWU4MDUxNDYxODEx._V1_.jpg">
<h3>Guardians of the Galaxy</h3>
<p>Action, Adventure, Comedy</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt3498820/?ref_=nv_sr_srsg_6">
<img src="https://m.media-amazon.com/images/M/MV5BMjQ0MTgyNjAxMV5BMl5BanBnXkFtZTgwNjUzMDkyODE#._V1_.jpg">
<h3>Captain America: Civil War</h3>
<p>Action, Adventure, Sci-Fi</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt0145487/?ref_=nv_sr_srsg_7">
<img src="https://images-na.ssl-images-amazon.com/images/I/71moJUZkLwL._SL1285_.jpg">
<h3>Spiderman</h3>
<p>Action, Adventure, Sci-Fi</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt4912910/?ref_=nv_sr_srsg_0">
<img src="https://cdn.collider.com/wp-content/uploads/2018/05/mission-impossible-fallout-poster-tom-cruise.jpg">
<h3>Mission Impossible: Fallout</h3>
<p>Action, Adventure, Thriller</p>
</a>
</div>
<br>
<!--6th row of movies-->
<div class="movies">
<a href="https://www.imdb.com/title/tt1790864/?ref_=nv_sr_srsg_3">
<img src="https://images-na.ssl-images-amazon.com/images/I/91mPBc21TcL._RI_.jpg">
<h3>The Maze Runner</h3>
<p>Action, Mystery, Sci-Fi</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt5095030/?ref_=nv_sr_srsg_3">
<img src="https://images-na.ssl-images-amazon.com/images/I/A1CGAvzql5L._SL1500_.jpg">
<h3>Ant-Man and the Wasp</h3>
<p>Action, Adventure, Comedy</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt2082221/?ref_=nv_sr_srsg_0">
<img src="http://mblogthumb1.phinf.naver.net/MjAxODAxMTNfMjk2/MDAxNTE1NzcyNTg1MTc0.NeCkyOl-gJwl4ksYNeAmYSHCHg9iRVLpCh0Qy4zFR1Ag.MfdAtUo9Efw0rx_8zKgkzAAj1azlUfm-ov3qgDuLRbUg.JPEG.zzid2/movie_image.jpg?type=w800">
<h3>범죄와의 전</h3>
<p>Action, Crime, Drama</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt2625030/?ref_=nv_sr_srsg_6">
<img src="http://mblogthumb4.phinf.naver.net/20130506_151/refine9_136781657095534Gd5_JPEG/movie_image.jpg?type=w2">
<h3>신세계</h3>
<p>Action, Crime, Drama</p>
</a>
</div>
</div>
<br>
<!--1st row of romance movies-->
<div id="romance">
<div class="movies">
<a href="https://www.imdb.com/title/tt1638002/?ref_=nv_sr_srsg_0">
<img src="https://kbimages1-a.akamaihd.net/beb95aaa-36b7-444d-8557-0cb7efa8e898/1200/1200/False/love-rosie-1.jpg">
<h3>Love, Rosie</h3>
<p>Comedy, Romance</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt2194499/?ref_=nv_sr_srsg_0">
<img src="https://m.media-amazon.com/images/M/MV5BMTA1ODUzMDA3NzFeQTJeQWpwZ15BbWU3MDgxMTYxNTk#._V1_.jpg">
<h3>About Time</h3>
<p>Comedy, Romance</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt1041829/?ref_=nv_sr_srsg_0">
<img src="https://m.media-amazon.com/images/M/MV5BOGM5YTNiYzktNmEwZC00ZjE5LWIyNzEtOTUwNDE0NmVkYzE3XkEyXkFqcGdeQXVyMTMxODk2OTU#._V1_.jpg">
<h3>The Proposal</h3>
<p>Comedy, Drama, Romance</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt1129423/">
<img src="https://m.media-amazon.com/images/M/MV5BMGZhYzFjY2ItNDVmZi00Y2Q1LWFmMDgtMzAwYTU3NTI3ZGU4XkEyXkFqcGdeQXVyMTMxMTY0OTQ#._V1_.jpg">
<h3>Fireproof</h3>
<p>Drama, Romance</p>
</a>
</div>
</div>
<br>
<!--1st row of comedy movies-->
<div id="comedy">
<div class="movies">
<a href="https://www.imdb.com/title/tt1638002/?ref_=nv_sr_srsg_0">
<img src="https://kbimages1-a.akamaihd.net/beb95aaa-36b7-444d-8557-0cb7efa8e898/1200/1200/False/love-rosie-1.jpg">
<h3>Love, Rosie</h3>
<p>Comedy, Romance</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt2194499/?ref_=nv_sr_srsg_0">
<img src="https://m.media-amazon.com/images/M/MV5BMTA1ODUzMDA3NzFeQTJeQWpwZ15BbWU3MDgxMTYxNTk#._V1_.jpg">
<h3>About Time</h3>
<p>Comedy, Romance</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt1041829/?ref_=nv_sr_srsg_0">
<img src="https://m.media-amazon.com/images/M/MV5BOGM5YTNiYzktNmEwZC00ZjE5LWIyNzEtOTUwNDE0NmVkYzE3XkEyXkFqcGdeQXVyMTMxODk2OTU#._V1_.jpg">
<h3>The Proposal</h3>
<p>Comedy, Drama, Romance</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt1129423/">
<img src="https://m.media-amazon.com/images/M/MV5BMGZhYzFjY2ItNDVmZi00Y2Q1LWFmMDgtMzAwYTU3NTI3ZGU4XkEyXkFqcGdeQXVyMTMxMTY0OTQ#._V1_.jpg">
<h3>Fireproof</h3>
<p>Drama, Romance</p>
</a>
</div>
</div>
</div>
</body>
</html>
Below is a working example of the code you provided. The changes are:
added position:relative; to .movies CSS class
added .grid-picture { position:relative; float:left; } to the CSS
added <br style="clear:both;"/> right before each movie category closing </div> tag in order to make sure that the div resizes to match the height of its content (old trick)
Note: I also tidied up your code a bit. You can run the example below to test it.
body {
margin: 0;
line-height: 1.6em;
font-size: 16px;
font-family: sans-serif;
}
.container {
width: 80%;
margin: auto;
overflow: hidden;
}
nav {
margin: 0;
color: #E52EAE;
z-index: 1;
}
nav ul {
list-style: none;
padding: 0;
}
nav li {
display: inline;
}
nav a{
text-decoration: none;
color: white;
padding-right: 18px;
padding-bottom: 5px;
text-align: center;
float: right;
}
.navbar {
margin-right: 227px;
position: relative;
font-size: 30px;
color: #22D8E5;
}
.navbar a:visited {
color: #22D8E5;
}
.navbar a:hover {
color: red;
}
#showcase {
background-image: url('http://getwallpapers.com/wallpaper/full/c/4/8/1367231-beautiful-black-cool-background-1920x1200-for-windows-7.jpg');
background-position: center right;
background-color: black;
background-size: 850px;
background-position: left;
height: 300px;
text-align: center;
color: white;
}
.movies {
position:relative;
float:left;
box-sizing: border-box;
width: 25%;
padding: 1px;
}
.movies img {
height: 500px;
width: 100%;
}
a:link {
text-decoration: none;
color: black;
}
a:visited {
color: coral;
}
a:hover {
color: red;
}
.grid-picture {
position:relative;
float:left;
}
<!DOCTYPE html>
<html>
<head>
<title>My Video Library</title>
<link rel="stylesheet" type="text/css" href="movies.css">
</head>
<body>
<section id="showcase">
<nav id="main-nav">
<div class="container">
<ul>
<li>Etc</li>
<li>Animation</li>
<li>LaughTime</li>
<li>Movies</li>
<li>Home</li>
</ul>
</div>
</nav>
<div class="container">
<h1>Movie List</h1>
<nav class="navbar">
<div class="container">
<ul>
<li>Drama</li>
<li>Comedy</li>
<li>Romance</li>
<li>Action</li>
</ul>
</div>
</nav>
</div>
</section>
<div class="grid-picture">
<!--First row of movies-->
<div id="action">
<div class="movies">
<a href="https://www.imdb.com/title/tt2911666/" target="_blank">
<img src="https://images-na.ssl-images-amazon.com/images/I/91atCmxi6hL._UR1200,1600_RI_.jpg" alt="john wick">
<h3>John Wick</h3>
<p>Action, Crime, Triller</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt2802144/" target="_blank">
<img src="https://cdn.collider.com/wp-content/uploads/2015/02/kingsman-the-secret-service-final-poster.jpg">
<h3>Kingsmen</h3>
<p>Action, Adventure, Comedy</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt2381249/" target="_blank">
<img src="https://images-na.ssl-images-amazon.com/images/I/81wcVvqV8pL._RI_.jpg">
<h3>Mission Impossible: Rogue Nation</h3>
<p>Action, Adventure, Thriller</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt0468569/" target="_blank">
<img src="https://images-na.ssl-images-amazon.com/images/I/91KkWf50SoL._SL1500_.jpg">
<h3>The Dark Knight</h3>
<p>Action, Crime, Drama</p>
</a>
</div>
<br>
<!--2nd row of movies-->
<div class="movies">
<a href="https://www.imdb.com/title/tt1431045/" target="_blank">
<img src="https://pics.filmaffinity.com/Deadpool-834516798-large.jpg">
<h3>Deadpool</h3>
<p>Action, Adventure, Comedy</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt3315342/" target="_blank">
<img src="https://vignette.wikia.nocookie.net/xmenmovies/images/2/22/Logan-Poster-5.jpg/revision/latest?cb=20170131012906">
<h3>Logan</h3>
<p>Action, Drama, Sci-Fi</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt6806448/" target="_blank">
<img src="https://musicart.xboxlive.com/7/e9225100-0000-0000-0000-000000000002/504/image.jpg?w=1920&h=1080">
<h3>Fast & Furious: Hobbs & Shaw</h3>
<p>Action, Adventure</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt0371746/" target="_blank">
<img src="https://cdn.collider.com/wp-content/uploads/2015/04/iron-man-1-poster.jpg">
<h3>Iron Man</h3>
<p>Action, Adventure, Sci-Fi</p>
</a>
</div>
<br>
<!--3rd row of movies-->
<div class="movies">
<a href="https://www.imdb.com/title/tt3501632/" target="_blank">
<img src="https://m.media-amazon.com/images/M/MV5BMjMyNDkzMzI1OF5BMl5BanBnXkFtZTgwODcxODg5MjI#._V1_.jpg">
<h3>Thor: Ragnarok</h3>
<p>Action, Adventure, Comedy</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt1631867/" target="_blank">
<img src="http://collider.com/wp-content/uploads/edge-of-tomorrow-poster3.jpg">
<h3>Edge of Tomorrow</h3>
<p>Action, Sci-Fi</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt2024469/?ref_=nv_sr_srsg_0" target="_blank">
<img src="https://m.media-amazon.com/images/M/MV5BOTI3NzcxMjkzMl5BMl5BanBnXkFtZTgwMDY0NTQ0MDE#._V1_.jpg">
<h3>Non-Stop</h3>
<p>Action, Thriller, Mystery</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt0936501/?ref_=nv_sr_srsg_0" target="_blank">
<img src="https://images-na.ssl-images-amazon.com/images/I/91gANPtj-7L._SL1500_.jpg">
<h3>Taken</h3>
<p>Action, Thriller</p>
</a>
</div>
<br>
<!--4th row of movies-->
<div class="movies">
<a href="https://www.imdb.com/title/tt4154756/?ref_=nv_sr_srsg_3" target="_blank">
<img src="https://m.media-amazon.com/images/M/MV5BMjMxNjY2MDU1OV5BMl5BanBnXkFtZTgwNzY1MTUwNTM#._V1_.jpg">
<h3>Avengers: Infinity War</h3>
<p>Action, Adventure, Sci-Fi</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt4154796/?ref_=nv_sr_srsg_0" target="_blank">
<img src="https://m.media-amazon.com/images/M/MV5BMTc5MDE2ODcwNV5BMl5BanBnXkFtZTgwMzI2NzQ2NzM#._V1_.jpg">
<h3>Avengers: Endgame</h3>
<p>Action, Adventure, Drama</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt6146586/?ref_=nv_sr_srsg_0" target="_blank">
<img src="https://i.pinimg.com/originals/1b/03/a1/1b03a1a68c4616f8fb203d00a2849a9a.jpg">
<h3>John Wick 3: Chapter 3 - Parabellum</h3>
<p>Action, Crime, Thriller</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt1270797/?ref_=nv_sr_srsg_0">
<img src="https://images-na.ssl-images-amazon.com/images/I/91ZwG8Ytb3L._RI_.jpg">
<h3>Venom</h3>
<p>Action, Sci-Fi, Thriller</p>
</a>
</div>
<br>
<!--5th row of movies-->
<div class="movies">
<a href="https://www.imdb.com/title/tt2015381/?ref_=nv_sr_srsg_0">
<img src="https://m.media-amazon.com/images/M/MV5BMTAwMjU5OTgxNjZeQTJeQWpwZ15BbWU4MDUxNDYxODEx._V1_.jpg">
<h3>Guardians of the Galaxy</h3>
<p>Action, Adventure, Comedy</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt3498820/?ref_=nv_sr_srsg_6">
<img src="https://m.media-amazon.com/images/M/MV5BMjQ0MTgyNjAxMV5BMl5BanBnXkFtZTgwNjUzMDkyODE#._V1_.jpg">
<h3>Captain America: Civil War</h3>
<p>Action, Adventure, Sci-Fi</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt0145487/?ref_=nv_sr_srsg_7">
<img src="https://images-na.ssl-images-amazon.com/images/I/71moJUZkLwL._SL1285_.jpg">
<h3>Spiderman</h3>
<p>Action, Adventure, Sci-Fi</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt4912910/?ref_=nv_sr_srsg_0">
<img src="https://cdn.collider.com/wp-content/uploads/2018/05/mission-impossible-fallout-poster-tom-cruise.jpg">
<h3>Mission Impossible: Fallout</h3>
<p>Action, Adventure, Thriller</p>
</a>
</div>
<br>
<!--6th row of movies-->
<div class="movies">
<a href="https://www.imdb.com/title/tt1790864/?ref_=nv_sr_srsg_3">
<img src="https://images-na.ssl-images-amazon.com/images/I/91mPBc21TcL._RI_.jpg">
<h3>The Maze Runner</h3>
<p>Action, Mystery, Sci-Fi</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt5095030/?ref_=nv_sr_srsg_3">
<img src="https://images-na.ssl-images-amazon.com/images/I/A1CGAvzql5L._SL1500_.jpg">
<h3>Ant-Man and the Wasp</h3>
<p>Action, Adventure, Comedy</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt2082221/?ref_=nv_sr_srsg_0">
<img src="http://mblogthumb1.phinf.naver.net/MjAxODAxMTNfMjk2/MDAxNTE1NzcyNTg1MTc0.NeCkyOl-gJwl4ksYNeAmYSHCHg9iRVLpCh0Qy4zFR1Ag.MfdAtUo9Efw0rx_8zKgkzAAj1azlUfm-ov3qgDuLRbUg.JPEG.zzid2/movie_image.jpg?type=w800">
<h3>범죄와의 전</h3>
<p>Action, Crime, Drama</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt2625030/?ref_=nv_sr_srsg_6">
<img src="http://mblogthumb4.phinf.naver.net/20130506_151/refine9_136781657095534Gd5_JPEG/movie_image.jpg?type=w2">
<h3>신세계</h3>
<p>Action, Crime, Drama</p>
</a>
</div>
<br style="clear:both;" />
</div>
<br>
<!--1st row of romance movies-->
<div id="romance">
<div class="movies">
<a href="https://www.imdb.com/title/tt1638002/?ref_=nv_sr_srsg_0">
<img src="https://kbimages1-a.akamaihd.net/beb95aaa-36b7-444d-8557-0cb7efa8e898/1200/1200/False/love-rosie-1.jpg">
<h3>Love, Rosie</h3>
<p>Comedy, Romance</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt2194499/?ref_=nv_sr_srsg_0">
<img src="https://m.media-amazon.com/images/M/MV5BMTA1ODUzMDA3NzFeQTJeQWpwZ15BbWU3MDgxMTYxNTk#._V1_.jpg">
<h3>About Time</h3>
<p>Comedy, Romance</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt1041829/?ref_=nv_sr_srsg_0">
<img src="https://m.media-amazon.com/images/M/MV5BOGM5YTNiYzktNmEwZC00ZjE5LWIyNzEtOTUwNDE0NmVkYzE3XkEyXkFqcGdeQXVyMTMxODk2OTU#._V1_.jpg">
<h3>The Proposal</h3>
<p>Comedy, Drama, Romance</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt1129423/">
<img src="https://m.media-amazon.com/images/M/MV5BMGZhYzFjY2ItNDVmZi00Y2Q1LWFmMDgtMzAwYTU3NTI3ZGU4XkEyXkFqcGdeQXVyMTMxMTY0OTQ#._V1_.jpg">
<h3>Fireproof</h3>
<p>Drama, Romance</p>
</a>
</div>
</div>
<br>
<!--1st row of comedy movies-->
<div id="comedy">
<div class="movies">
<a href="https://www.imdb.com/title/tt1638002/?ref_=nv_sr_srsg_0">
<img src="https://kbimages1-a.akamaihd.net/beb95aaa-36b7-444d-8557-0cb7efa8e898/1200/1200/False/love-rosie-1.jpg">
<h3>Love, Rosie</h3>
<p>Comedy, Romance</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt2194499/?ref_=nv_sr_srsg_0">
<img src="https://m.media-amazon.com/images/M/MV5BMTA1ODUzMDA3NzFeQTJeQWpwZ15BbWU3MDgxMTYxNTk#._V1_.jpg">
<h3>About Time</h3>
<p>Comedy, Romance</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt1041829/?ref_=nv_sr_srsg_0">
<img src="https://m.media-amazon.com/images/M/MV5BOGM5YTNiYzktNmEwZC00ZjE5LWIyNzEtOTUwNDE0NmVkYzE3XkEyXkFqcGdeQXVyMTMxODk2OTU#._V1_.jpg">
<h3>The Proposal</h3>
<p>Comedy, Drama, Romance</p>
</a>
</div>
<div class="movies">
<a href="https://www.imdb.com/title/tt1129423/">
<img src="https://m.media-amazon.com/images/M/MV5BMGZhYzFjY2ItNDVmZi00Y2Q1LWFmMDgtMzAwYTU3NTI3ZGU4XkEyXkFqcGdeQXVyMTMxMTY0OTQ#._V1_.jpg">
<h3>Fireproof</h3>
<p>Drama, Romance</p>
</a>
</div>
<br style="clear:both;" />
</div>
</div>
</body>
</html>
A link to an anchor only scrolls the page, so if you set a link to an anchor at the bottom of the page the site cannot scroll further than until it reaches the end of its content.
This could be your issue here. You can easily test this if you set the height of the
.grid-picture container to a huge value to make the page scroll beyound the height of the actual content.
I think you are looking for this gallery filter
filterSelection("all")
function filterSelection(c) {
var x, i;
x = document.getElementsByClassName("column");
if (c == "all") c = "";
for (i = 0; i < x.length; i++) {
w3RemoveClass(x[i], "show");
if (x[i].className.indexOf(c) > -1) w3AddClass(x[i], "show");
}
}
function w3AddClass(element, name) {
var i, arr1, arr2;
arr1 = element.className.split(" ");
arr2 = name.split(" ");
for (i = 0; i < arr2.length; i++) {
if (arr1.indexOf(arr2[i]) == -1) {element.className += " " + arr2[i];}
}
}
function w3RemoveClass(element, name) {
var i, arr1, arr2;
arr1 = element.className.split(" ");
arr2 = name.split(" ");
for (i = 0; i < arr2.length; i++) {
while (arr1.indexOf(arr2[i]) > -1) {
arr1.splice(arr1.indexOf(arr2[i]), 1);
}
}
element.className = arr1.join(" ");
}
// Add active class to the current button (highlight it)
var btnContainer = document.getElementById("myBtnContainer");
var btns = btnContainer.getElementsByClassName("btn");
for (var i = 0; i < btns.length; i++) {
btns[i].addEventListener("click", function(){
var current = document.getElementsByClassName("active");
current[0].className = current[0].className.replace(" active", "");
this.className += " active";
});
}
* {
box-sizing: border-box;
}
body {
background-color: #f1f1f1;
padding: 20px;
font-family: Arial;
}
/* Center website */
.main {
max-width: 1000px;
margin: auto;
}
h1 {
font-size: 50px;
word-break: break-all;
}
.row {
margin: 10px -16px;
}
/* Add padding BETWEEN each column */
.row,
.row > .column {
padding: 8px;
}
/* Create three equal columns that floats next to each other */
.column {
float: left;
width: 33.33%;
display: none; /* Hide all elements by default */
}
/* Clear floats after rows */
.row:after {
content: "";
display: table;
clear: both;
}
/* Content */
.content {
background-color: white;
padding: 10px;
}
/* The "show" class is added to the filtered elements */
.show {
display: block;
}
/* Style the buttons */
.btn {
border: none;
outline: none;
padding: 12px 16px;
background-color: white;
cursor: pointer;
}
.btn:hover {
background-color: #ddd;
}
.btn.active {
background-color: #666;
color: white;
}* {
box-sizing: border-box;
}
body {
background-color: #f1f1f1;
padding: 20px;
font-family: Arial;
}
/* Center website */
.main {
max-width: 1000px;
margin: auto;
}
h1 {
font-size: 50px;
word-break: break-all;
}
.row {
margin: 10px -16px;
}
/* Add padding BETWEEN each column */
.row,
.row > .column {
padding: 8px;
}
/* Create three equal columns that floats next to each other */
.column {
float: left;
width: 33.33%;
display: none; /* Hide all elements by default */
}
/* Clear floats after rows */
.row:after {
content: "";
display: table;
clear: both;
}
/* Content */
.content {
background-color: white;
padding: 10px;
}
/* The "show" class is added to the filtered elements */
.show {
display: block;
}
/* Style the buttons */
.btn {
border: none;
outline: none;
padding: 12px 16px;
background-color: white;
cursor: pointer;
}
.btn:hover {
background-color: #ddd;
}
.btn.active {
background-color: #666;
color: white;
}
<!-- MAIN (Center website) -->
<div class="main">
<h1>MYLOGO.COM</h1>
<hr>
<h2>PORTFOLIO</h2>
<div id="myBtnContainer">
<button class="btn active" onclick="filterSelection('all')"> Show all</button>
<button class="btn" onclick="filterSelection('nature')"> Nature</button>
<button class="btn" onclick="filterSelection('cars')"> Cars</button>
<button class="btn" onclick="filterSelection('people')"> People</button>
</div>
<!-- Portfolio Gallery Grid -->
<div class="row">
<div class="column nature">
<div class="content">
<img src="https://www.w3schools.com/w3images/mountains.jpg" alt="Mountains" style="width:100%">
<h4>Mountains</h4>
<p>Lorem ipsum dolor..</p>
</div>
</div>
<div class="column nature">
<div class="content">
<img src="https://www.w3schools.com/w3images/lights.jpg" alt="Lights" style="width:100%">
<h4>Lights</h4>
<p>Lorem ipsum dolor..</p>
</div>
</div>
<div class="column nature">
<div class="content">
<img src="https://www.w3schools.com/w3images/nature.jpg" alt="Nature" style="width:100%">
<h4>Forest</h4>
<p>Lorem ipsum dolor..</p>
</div>
</div>
<div class="column cars">
<div class="content">
<img src="https://www.w3schools.com/w3images/cars1.jpg" alt="Car" style="width:100%">
<h4>Retro</h4>
<p>Lorem ipsum dolor..</p>
</div>
</div>
<div class="column cars">
<div class="content">
<img src="https://www.w3schools.com/w3images/cars2.jpg" alt="Car" style="width:100%">
<h4>Fast</h4>
<p>Lorem ipsum dolor..</p>
</div>
</div>
<div class="column cars">
<div class="content">
<img src="https://www.w3schools.com/w3images/cars3.jpg" alt="Car" style="width:100%">
<h4>Classic</h4>
<p>Lorem ipsum dolor..</p>
</div>
</div>
<div class="column people">
<div class="content">
<img src="https://www.w3schools.com/w3images/people1.jpg" alt="Car" style="width:100%">
<h4>Girl</h4>
<p>Lorem ipsum dolor..</p>
</div>
</div>
<div class="column people">
<div class="content">
<img src="https://www.w3schools.com/w3images/people2.jpg" alt="Car" style="width:100%">
<h4>Man</h4>
<p>Lorem ipsum dolor..</p>
</div>
</div>
<div class="column people">
<div class="content">
<img src="https://www.w3schools.com/w3images/people3.jpg" alt="Car" style="width:100%">
<h4>Woman</h4>
<p>Lorem ipsum dolor..</p>
</div>
</div>
<!-- END GRID -->
</div>
<!-- END MAIN -->
</div>

Menu logos are in the center of the div but not the titles - Bootstrap

I have been trying to create a responsive menu for the mobile browser of my site and it has four links. I have given 25% width for each of them. The problem is, although its logos stay center their titles don't. You can notice for the snippet that the titles are not in the center of their div.
What is the problem here? What am I doing wrong? Can you suggest how can I keep these titles center as well?
this is the current state:
I'm trying to make it something like this:
The snippet:
.menu {
position: fixed;
bottom: 0;
width: 100%;
background-color: #434A54;
color: white;
font-size: 12px;
padding-top: 7px;
}
a.main-link:link,
a.main-link:visited {
background-color: #434A54;
color: white;
text-decoration: none;
display: inline-block;
width: 25%;
}
.logo {
width: 24px;
height: 24px;
margin-left: auto;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container menu">
<div class="row">
<a href="start.html" class="main-link">
<div class="col-3"> <img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo"/> <br>
LINK1
</div>
</a>
<a href="calculator-home.html" class="main-link">
<div class="col-3"> <img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo"/> <br>
LINK222
</div>
</a>
<a href="contact.html" class="main-link">
<div class="col-3"> <img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo"/> <br>
LINK33333
</div>
</a>
<a href="about.html" class="main-link">
<div class="col-3"> <img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo"/> <br>
LINK4444444
</div>
</a>
</div>
</div>
Columns should be direct child of rows.
Add text center class to the columns. Put the anchor tag inside of columns and make it display:block. And the image and menu title should be placed inside the anchor tag.
/*This css is not required. */
img{
width:25px;
height:25px;
}
a.main-link:link,
a.main-link:visited {
text-decoration: none;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-3 text-center">
<a href="start.html" class="main-link d-block">
<img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo " />
<div> LINK1 </div>
</a>
</div>
<div class="col-3 text-center">
<a href="start.html" class="main-link d-block">
<img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo " />
<div> LINK1 </div>
</a>
</div>
<div class="col-3 text-center">
<a href="start.html" class="main-link d-block">
<img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo " />
<div> LINK1 </div>
</a>
</div>
</div>
</div>
If you change the html code and add the image before the text inside the anchor tag then add text-align: center you'll get the same result
check my code:
.menu {
position: fixed;
bottom: 0;
width: 100%;
background-color: #434A54;
color: white;
font-size: 12px;
padding-top: 7px;
}
.main-link {
text-align: center
}
a.main-link:link,
a.main-link:visited {
background-color: #434A54;
color: white;
text-decoration: none;
display: inline-block;
width: 25%;
}
.logo {
width: 24px;
height: 24px;
margin-left: auto;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="container menu">
<div class="row">
<a href="start.html" class="main-link">
<img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo" /><br />
<span class="col-3">LINK1
</span>
</a>
<a href="calculator-home.html" class="main-link">
<img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo" /> <br>
<span class="col-3">LINK222
</span>
</a>
<a href="contact.html" class="main-link">
<img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo" /> <br>
<span class="col-3">LINK33333
</span>
</a>
<a href="about.html" class="main-link">
<img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo" /><br />
<span class="col-3">LINK4444444
</span>
</a>
</div>
</div>

img-circle class becomes oval in shape after using customized css in bootstrap

I am new to bootstrap, and I have to make an image circle in shape using bootstrap. When I add my own CSS for this image, it becomes an oval in shape. Following is the html and css for this.
CSS:
.person {
border: 10px solid transparent;
margin-bottom: 25px;
width: 80%;
height: 80%;
opacity: 0.7;
}
.person:hover {
border-color: #f1f1f1;
}
HTML:
<div class="row">
<div class="col-sm-4">
<p>
<strong>Test Member 1</strong>
</p>
<br />
<a href="#demo" data-toggle="collapse">
<img src="images/bandmember.jpg" class="img-circle person" alt="Band Manager" />
</a>
<div id="demo" class="collapse">
<p>Guitarist and Lead Vocalist</p>
<p>Loves long walks on the beach</p>
<p>Member since 1988</p>
</div>
</div>
<div class="col-sm-4">
<p><strong>Test Member 2</strong></p><br />
<a href="#demo2" data-toggle="collapse">
<img src="images/bandmember.jpg" class="img-circle person" alt="Random Name">
</a>
<div id="demo2" class="collapse">
<p>Guitarist and Lead Vocalist</p>
<p>Loves long walks on the beach</p>
<p>Member since 1988</p>
</div>
</div>
<div class="col-sm-4">
<p><strong>Test Member 3</strong></p><br />
<a href="#demo3" data-toggle="collapse">
<img src="images/bandmember.jpg" class="img-circle person" alt="Random Name">
</a>
<div id="demo3" class="collapse">
<p>Guitarist and Lead Vocalist</p>
<p>Loves long walks on the beach</p>
<p>Member since 1988</p>
</div>
</div>
</div>
These styles:
width: 80%;
height: 80%;
...don't set the width/height as relative to the current size. Rather, they set the width/height relative to the containing block. Thus, you're almost guaranteed to have the width and height not match.
You will need to use different sizing units other than %.
Hi please check this solution it might be help you.
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<style type="text/css">
.person
{
border: 10px solid transparent;
height: 200px;
width: 200px;
padding: 10px;
opacity: 0.7;
}
.person:hover
{
border-color: #f1f1f1;
}
</style>
</head>
<body>
<div class="row">
<div class="col-sm-4">
<p>
<strong>Test Member 1</strong>
</p>
<br />
<a href="#demo" data-toggle="collapse">
<img src="images/bandmember.jpg" class="img-responsive img-circle person" alt="Random Name">
</a>
<div id="demo" class="collapse">
<p>
Guitarist and Lead Vocalist</p>
<p>
Loves long walks on the beach</p>
<p>
Member since 1988</p>
</div>
</div>
<div class="col-sm-4">
<p>
<strong>Test Member 2</strong></p>
<br />
<a href="#demo2" data-toggle="collapse">
<img src="images/bandmember.jpg" class="img-responsive img-circle person" alt="Random Name">
</a>
<div id="demo2" class="collapse">
<p>
Guitarist and Lead Vocalist</p>
<p>
Loves long walks on the beach</p>
<p>
Member since 1988</p>
</div>
</div>
<div class="col-sm-4">
<p>
<strong>Test Member 3</strong></p>
<br />
<a href="#demo3" data-toggle="collapse">
<img src="images/bandmember.jpg" class="img-responsive img-circle person" alt="Random Name">
</a>
<div id="demo3" class="collapse">
<p>
Guitarist and Lead Vocalist</p>
<p>
Loves long walks on the beach</p>
<p>
Member since 1988</p>
</div>
</div>
</div>
</body>
</html>

Flexbox margin-top: auto not pushing item to bottom

I have want the UL to push to the bottom of the container for each item. I have margin-top:auto set for the item but it is not working. I have another demo that works but this is the one that I need to use. Any help?
.featured-products-carousel {
display: flex;
flex-wrap: nowrap;
justify-content: space-between;
margin: 0 auto;
max-width: 1150px;
width: 80%;
}
.featured-products-carousel .item {
background-color: white;
padding: 20px;
align-items: stretch;
display: flex;
flex-direction: column;
margin: 10px;
padding: 0;
flex: 1 1 auto;
flex-wrap: wrap;
}
.featured-products-carousel .item h2 {
text-align: center;
padding: 8px 5px;
}
.featured-products-carousel .item .featured-product-description {
margin-bottom: auto;
}
.featured-products-carousel .item .featured-products-links {
margin-top: auto;
}
.featured-products-carousel .item ul {
margin-top: auto;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="featured-products-carousel" role="listbox">
<div class="item active visible-md visible-sm visible-lg product-item col-xs-12 col-md-3 col-sm-6" id="2">
<span class="h2-span">
<h2 class="h2-height"> [product-id] </h2>
</span>
<div class="product-image">
<a href="/products/[[product-id]]">
<img src="http://placehold.it/400x250" alt="[item-description]" class="img-responsive-center">
</a>
</div>
<p class="featured-product-description"> Description Text. Lots and lots of great content about a particular part. Description Text. Lots and lots of great content about a particular part.</p>
<ul class="list-unstyled">
<li>
<a href="/products/[product-id]">
More About [product-id] »
</a>
</li>
<li>
Datasheet
</li>
</ul>
</div>
<div class="item active visible-md visible-sm visible-lg product-item col-xs-12 col-md-3 col-sm-6" id="2">
<span class="h2-span">
<h2 class="h2-height"> [product-id] </h2>
</span>
<div class="product-image">
<a href="/products/[[product-id]]">
<img src="http://placehold.it/400x250" alt="[item-description]" class="img-responsive-center">
</a>
</div>
<p class="featured-product-description"> Description Text. Lots and lots of great content about a particular part. </p>
<ul class="list-unstyled">
<li>
<a href="/products/[product-id]">
More About [product-id] »
</a>
</li>
<li>
Datasheet
</li>
</ul>
</div>
<div class="item active visible-md visible-sm visible-lg product-item col-xs-12 col-md-3 col-sm-6" id="2">
<span class="h2-span">
<h2 class="h2-height"> [product-id] </h2>
</span>
<div class="product-image">
<a href="/products/[[product-id]]">
<img src="http://placehold.it/400x250" alt="[item-description]" class="img-responsive-center">
</a>
</div>
<p class="featured-product-description"> Description Text. Lots and lots of great content about a particular part. Description Text. Lots and lots of great content about a particular part.</p>
<ul class="list-unstyled">
<li>
<a href="/products/[product-id]">
More About [product-id] »
</a>
</li>
<li>
Datasheet
</li>
</ul>
</div>
<div class="item active visible-md visible-sm visible-lg product-item col-xs-12 col-md-3 col-sm-6" id="2">
<span class="h2-span">
<h2 class="h2-height"> [product-id] </h2>
</span>
<div class="product-image">
<a href="/products/[[product-id]]">
<img src="http://placehold.it/400x250" alt="[item-description]" class="img-responsive-center">
</a>
</div>
<p class="featured-product-description"> Description Text. Lots and lots of great content about a particular part. </p>
<ul class="list-unstyled">
<li>
<a href="/products/[product-id]">
More About [product-id] »
</a>
</li>
<li>
Datasheet
</li>
</ul>
</div>
</div>
The parent element isn't display: flex; even though you've specified that because there is another rule overwriting it with display: block!important;.
display: block!important is coming from bootstrap.css on line 6636 and another on line 6554.
.featured-products-carousel {
display: flex;
flex-wrap: nowrap;
justify-content: space-between;
margin: 0 auto;
max-width: 1150px;
width: 80%;
}
.featured-products-carousel .item {
background-color: white;
padding: 20px;
align-items: stretch;
display: flex!important;
flex-direction: column;
margin: 10px;
padding: 0;
flex: 1 1 auto;
flex-wrap: wrap;
}
.featured-products-carousel .item h2 {
text-align: center;
padding: 8px 5px;
}
.featured-products-carousel .item .featured-product-description {
margin-bottom: auto;
}
.featured-products-carousel .item .featured-products-links {
margin-top: auto;
}
.featured-products-carousel .item ul {
margin-top: auto;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="featured-products-carousel" role="listbox">
<div class="item active visible-md visible-sm visible-lg product-item col-xs-12 col-md-3 col-sm-6" id="2">
<span class="h2-span">
<h2 class="h2-height"> [product-id] </h2>
</span>
<div class="product-image">
<a href="/products/[[product-id]]">
<img src="http://placehold.it/400x250" alt="[item-description]" class="img-responsive-center">
</a>
</div>
<p class="featured-product-description"> Description Text. Lots and lots of great content about a particular part. Description Text. Lots and lots of great content about a particular part.</p>
<ul class="list-unstyled">
<li>
<a href="/products/[product-id]">
More About [product-id] »
</a>
</li>
<li>
Datasheet
</li>
</ul>
</div>
<div class="item active visible-md visible-sm visible-lg product-item col-xs-12 col-md-3 col-sm-6" id="2">
<span class="h2-span">
<h2 class="h2-height"> [product-id] </h2>
</span>
<div class="product-image">
<a href="/products/[[product-id]]">
<img src="http://placehold.it/400x250" alt="[item-description]" class="img-responsive-center">
</a>
</div>
<p class="featured-product-description"> Description Text. Lots and lots of great content about a particular part. </p>
<ul class="list-unstyled">
<li>
<a href="/products/[product-id]">
More About [product-id] »
</a>
</li>
<li>
Datasheet
</li>
</ul>
</div>
<div class="item active visible-md visible-sm visible-lg product-item col-xs-12 col-md-3 col-sm-6" id="2">
<span class="h2-span">
<h2 class="h2-height"> [product-id] </h2>
</span>
<div class="product-image">
<a href="/products/[[product-id]]">
<img src="http://placehold.it/400x250" alt="[item-description]" class="img-responsive-center">
</a>
</div>
<p class="featured-product-description"> Description Text. Lots and lots of great content about a particular part. Description Text. Lots and lots of great content about a particular part.</p>
<ul class="list-unstyled">
<li>
<a href="/products/[product-id]">
More About [product-id] »
</a>
</li>
<li>
Datasheet
</li>
</ul>
</div>
<div class="item active visible-md visible-sm visible-lg product-item col-xs-12 col-md-3 col-sm-6" id="2">
<span class="h2-span">
<h2 class="h2-height"> [product-id] </h2>
</span>
<div class="product-image">
<a href="/products/[[product-id]]">
<img src="http://placehold.it/400x250" alt="[item-description]" class="img-responsive-center">
</a>
</div>
<p class="featured-product-description"> Description Text. Lots and lots of great content about a particular part. </p>
<ul class="list-unstyled">
<li>
<a href="/products/[product-id]">
More About [product-id] »
</a>
</li>
<li>
Datasheet
</li>
</ul>
</div>
</div>

Height 100% on child when parent doesn't have a fixed width

Ok, I'm having some issues getting height:100; on my hover to work in my portfolio section, I tried a bunch of solutions from similar questions but nothing seems to be working. Also I got it to work with media queries but it's a bunch of extra code and I know there is another way to do it I just can't figure it out!
Check out my html:
<!-- Begin Portfolio -->
<section id="section2">
<div class="container portfolio">
<!-- Page Title -->
<div class="row page-title-2">
<div class="col-lg-12">
<h3>Portfolio</h3>
<hr>
<p>We also create some other stuff.</p>
</div>
</div>
<!-- Portfolio Filter -->
<div class="container text-center">
<ul class="nav nav-pills">
<li class="filter" data-filter="all">all</li>
<li class="filter" data-filter="print">print</li>
<li class="filter" data-filter="web">web</li>
<li class="filter" data-filter="branding">branding</li>
<li class="filter" data-filter="branding">illustration</li>
</ul>
</div>
<!-- Portfolio Items -->
<div class="container port-holder">
<ul id="myPortfolio" class="no-padding">
<li class="item branding col-xs-4 no-padding">
<a data-toggle="modal" href="projects/project-1.html" data-target="#myModal">
<img src="img/projects/thumbs/branding1.jpg" alt="..." />
<span class="portfolio-hover">
<span>
<h4>Beach Sand</h4>
<em>Branding</em>
</span>
</span>
</a>
</li>
<li class="item web col-xs-4 no-padding">
<a data-toggle="modal" href="projects/project-2.html" data-target="#myModal">
<img src="img/projects/thumbs/web1.jpg" alt="..." />
<span class="portfolio-hover">
<span>
<h4>B&W Scene</h4>
<em>Web Design</em>
</span>
</span>
</a>
</li>
<li class="item print col-xs-4 no-padding">
<a data-toggle="modal" href="projects/project-3.html" data-target="#myModal">
<img src="img/projects/thumbs/print1.jpg" alt="..." />
<span class="portfolio-hover">
<span>
<h4>Metal</h4>
<em>Print</em>
</span>
</span>
</a>
</li>
<li class="item branding col-xs-4 no-padding">
<a data-toggle="modal" href="projects/project-4.html" data-target="#myModal">
<img src="img/projects/thumbs/branding2.jpg" alt="..." />
<span class="portfolio-hover">
<span>
<h4>Bridge Cityscape</h4>
<em>Branding</em>
</span>
</span>
</a>
</li>
<li class="item print col-xs-4 no-padding">
<a data-toggle="modal" href="projects/project-5.html" data-target="#myModal">
<img src="img/projects/thumbs/print2.jpg" alt="..." />
<span class="portfolio-hover">
<span>
<h4>Camera</h4>
<em>Print</em>
</span>
</span>
</a>
</li>
<li class="item branding col-xs-4 no-padding">
<a data-toggle="modal" href="projects/project-6.html" data-target="#myModal">
<img src="img/projects/thumbs/branding3.jpg" alt="..." />
<span class="portfolio-hover">
<span>
<h4>B&W City</h4>
<em>Branding</em>
</span>
</span>
</a>
</li>
<li class="item web col-xs-4 no-padding">
<a data-toggle="modal" href="projects/project-7.html" data-target="#myModal">
<img src="img/projects/thumbs/web2.jpg" alt="..." />
<span class="portfolio-hover">
<span>
<h4>Objects</h4>
<em>Web Design</em>
</span>
</span>
</a>
</li>
<li class="item print col-xs-4 no-padding">
<a data-toggle="modal" href="projects/project-8.html" data-target="#myModal">
<img src="img/projects/thumbs/print3.jpg" alt="..." />
<span class="portfolio-hover">
<span>
<h4>Paradise</h4>
<em>Print</em>
</span>
</span>
</a>
</li>
<li class="item web col-xs-4 no-padding">
<a data-toggle="modal" href="projects/project-9.html" data-target="#myModal">
<img src="img/projects/thumbs/web3.jpg" alt="..." />
<span class="portfolio-hover">
<span>
<h4>Eary</h4>
<em>Web</em>
</span>
</span>
</a>
</li>
</ul>
</div>
</div>
</section>
<!-- End Portfolio -->
My CSS for the hover:
.portfolio ul li:hover span.portfolio-hover {
opacity: 1;
}
.portfolio img {
max-width: 100%;
width: 100%;
height: 100% !important;
}
span.portfolio-hover {
background: rgba(39,39,39,0.95);
color: #8e8e8e;
width: 100%;
height: 100%;
display: table;
left: 0;
position: absolute;
top: 0;
bottom: 0;
opacity: 0;
-webkit-transition: opacity 500ms;
-moz-transition: opacity 500ms;
-o-transition: opacity 500ms;
transition: opacity 500ms;
}
span.portfolio-hover span {
display: table-cell;
text-align: center;
vertical-align: middle;
}
Any help is greatly appreciated!
You can also see the live version here, just go to portfolio section and hover an image.
Change span.portfolio-hover from display: table, to display:block
Try using the Height in the Pixels as of the Original Image or Whatever ur Imageheight is
height:388px
Thanks