Can't click on button element when nested inside of Div's? - html

I have a button nested inside of 3 div's. The innermost div where the button is nested has a higher z-index of all the other div's. Still cannot click the button. What am I doing wrong?
* {
font-family: 'Raleway', sans-serif;
}
#main {
background: url('../image/bg2.jpg');
background-size: cover;
background-position: center;
height: 720px;
width: 2000px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
margin-top: -50px;
position: relative;
z-index: -50;
}
#content {
z-index: -25;
}
#content h3 {
font-size: 8rem;
color: #fff;
}
#button {
z-index: 99999!important;
}
.submain h3 {
display: inline;
padding: 25px;
}
<!--Main-->
<div id="main">
<div id="content">
<h3><i class="fa fa-cogs" aria-hidden="true"></i>DNS<sup>2</sup></a></h3>
<div id="button">
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">Learn More</button>
</div>
<div class="collapse" id="collapseExample">
<div class="card card-block">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras molestie dignissim lacus id tempus. Donec malesuada efficitur ultricies. Vestibulum nec lobortis est, quis efficitur nunc. Proin finibus, massa in pharetra tempus, velit ante dictum massa,
eget porttitor arcu tellus eu orci. Quisque vitae ante lacus. In tortor purus, tristique nec felis ac, accumsan malesuada risus. Nam consectetur eget lacus vel condimentum. Donec in nisl volutpat, cursus arcu ac, mattis neque. Pellentesque metus
nisi, maximus eget metus sed, tincidunt euismod nisl. Quisque sed ipsum imperdiet, semper quam ac, varius leo.
</div>
</div>
</div>
</div>

please change that
z-index: -50;
to any positive value.
Then It will work

Here is 2 ways :
A)
body {
position: relative;
z-index: 0;
}
*{
font-family: 'Raleway', sans-serif;
}
body { position: relative; z-index: 0; }
#main {
background: url('../image/bg2.jpg');
background-size: cover;
background-position: center;
height: 720px;
width: 2000px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
margin-top: -50px;
position: relative;
z-index: -50;
}
#content{
z-index: -25;
}
#content h3{
font-size: 8rem;
color: #fff;
}
#button{
z-index: 999!important;
}
.submain h3{
display: inline;
padding: 25px;
}
<div id="main">
<div id="content">
<h3><i class="fa fa-cogs" aria-hidden="true"></i>DNS<sup>2</sup></a></h3>
<div id ="button">
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">Learn More</button>
</div>
<div class="collapse" id="collapseExample">
<div class="card card-block">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras molestie dignissim lacus id tempus. Donec malesuada efficitur ultricies. Vestibulum nec lobortis est, quis efficitur nunc. Proin finibus, massa in pharetra tempus, velit ante dictum massa, eget porttitor arcu tellus eu orci. Quisque vitae ante lacus. In tortor purus, tristique nec felis ac, accumsan malesuada risus. Nam consectetur eget lacus vel condimentum. Donec in nisl volutpat, cursus arcu ac, mattis neque. Pellentesque metus nisi, maximus eget metus sed, tincidunt euismod nisl. Quisque sed ipsum imperdiet, semper quam ac, varius leo.
</div>
</div>
</div>
OR
B)
#main {
z-index:0;
//more code....
}
*{
font-family: 'Raleway', sans-serif;
}
#main {
background: url('../image/bg2.jpg');
background-size: cover;
background-position: center;
height: 720px;
width: 2000px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
margin-top: -50px;
position: relative;
z-index: 0;
}
#content{
z-index: -25;
}
#content h3{
font-size: 8rem;
color: #fff;
}
#button{
z-index: 999!important;
}
.submain h3{
display: inline;
padding: 25px;
}
<div id="main">
<div id="content">
<h3><i class="fa fa-cogs" aria-hidden="true"></i>DNS<sup>2</sup></a></h3>
<div id ="button">
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">Learn More</button>
</div>
<div class="collapse" id="collapseExample">
<div class="card card-block">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras molestie dignissim lacus id tempus. Donec malesuada efficitur ultricies. Vestibulum nec lobortis est, quis efficitur nunc. Proin finibus, massa in pharetra tempus, velit ante dictum massa, eget porttitor arcu tellus eu orci. Quisque vitae ante lacus. In tortor purus, tristique nec felis ac, accumsan malesuada risus. Nam consectetur eget lacus vel condimentum. Donec in nisl volutpat, cursus arcu ac, mattis neque. Pellentesque metus nisi, maximus eget metus sed, tincidunt euismod nisl. Quisque sed ipsum imperdiet, semper quam ac, varius leo.
</div>
</div>
</div>

button is descendant of elements which are overlapped by body due to negative z-index of #main and #content. You can remove those negative z-indexes.
Demo:
* {
font-family: 'Raleway', sans-serif;
}
#main {
background: url('../image/bg2.jpg');
background-size: cover;
background-position: center;
height: 720px;
width: 2000px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
margin-top: -50px;
position: relative;
}
#content h3 {
font-size: 8rem;
color: #fff;
}
#button {
z-index: 99999!important;
}
.submain h3 {
display: inline;
padding: 25px;
}
<!--Main-->
<div id="main">
<div id="content">
<h3><i class="fa fa-cogs" aria-hidden="true"></i>DNS<sup>2</sup></a></h3>
<div id="button">
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">Learn More</button>
</div>
<div class="collapse" id="collapseExample">
<div class="card card-block">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras molestie dignissim lacus id tempus. Donec malesuada efficitur ultricies. Vestibulum nec lobortis est, quis efficitur nunc. Proin finibus, massa in pharetra tempus, velit ante dictum massa,
eget porttitor arcu tellus eu orci. Quisque vitae ante lacus. In tortor purus, tristique nec felis ac, accumsan malesuada risus. Nam consectetur eget lacus vel condimentum. Donec in nisl volutpat, cursus arcu ac, mattis neque. Pellentesque metus
nisi, maximus eget metus sed, tincidunt euismod nisl. Quisque sed ipsum imperdiet, semper quam ac, varius leo.
</div>
</div>
</div>
</div>

Related

Images point through bottom of grid column

I am trying to make cards highlighting projects for a test portfolio. When I work on it in Codepen on my desktop it looks fine, but when I look on mobile the project images are poking through the bottom. Setting a bottom left and right margin to match the bottom of the card works on mobile but then it is formatted wrong on desktop.
* {
box-sizing: border-box;
margin: 0;
padding: 0;
background-color: #143861;
}
.section-header {
color: white;
font-size: 20px;
text-align: center;
backgroun-color: ;
}
.grid-wrapper {
display: grid;
height: 100vh;
width: 100vw;
grid-template-rows: .5fr 1fr 4fr 1fr;
grid-template-columns: minmax(0, 1fr);
overflow: auto;
text-align: center;
}
.header {
display: flex;
align-items: center;
}
.profile-image {
left: 0;
}
.about {
margin-top: 20rem;
margin-bottom: 20rem;
margin-left: 40px;
margin-right: 40px;
text-align: left;
color: white;
font-size: 20px;
}
.nav {
display: flex;
text-align: center;
gap: 2rem;
padding: 1rem;
position: fixed;
}
<DOCTYPE! html>
<html>
<body>
<div class="grid-wrapper">
<div class="header">
<img id="profile-image" src="https://via.placeholder.com/140x100"></img>
<div class="nav">
<div class="nav-links">About</div>
<div class="nav-links">Projects</div>
<div class="nav-links">Contact</div>
</div>
</div>
<section id="about">
<div class="about">
<h1 class="section-header">About</h1><br>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed felis quam, cursus vel scelerisque eu, sollicitudin ac neque. Mauris in dui a lacus rutrum bibendum et at turpis. Curabitur velit felis, consequat vel leo in, molestie egestas arcu. Aenean condimentum,
est nec viverra suscipit, nibh dui fermentum justo, eget eleifend turpis felis interdum nulla. Etiam eros turpis, faucibus ac fermentum a, sodales a lacus. Praesent vulputate, justo tristique mattis feugiat, ipsum nunc commodo turpis, in euismod
sem quam sit amet augue. Donec iaculis malesuada hendrerit. Proin venenatis, nibh in pulvinar sollicitudin, dui dui placerat metus, eu sodales tellus sapien ut urna. Phasellus et ipsum accumsan, pulvinar felis vitae, maximus metus. Vestibulum
sodales rhoncus enim, ut convallis massa scelerisque id. Nunc venenatis lacus eu finibus vulputate. Proin tincidunt turpis at ipsum porttitor varius. Sed accumsan arcu in odio dapibus, nec elementum dolor feugiat.
</p>
</div>
<section id="projects">
<h1 class="section-header">Projects</h1>
<div class="content">
<div class="project">
<img src="https://content.syndigo.com/asset/56a5cb78-9825-423a-a9df-fa0f5f2438f7/480.jpeg" alt="project image" class="project-image"></img>
<a class="project-link" href="https://codepen.io/nanglewi/full/qBVENGg" target="_blank">Cherry MX Product Landing Page</a>
</div>

Can I change how Flexbox shrinks?

I'm trying to replicate the sections on the following page
I'm using flexbox in my version, however my version using flexbox seems to adjust to smaller screen sizes differently. For example the original that I'm trying to copy eats into the margin first as the screen gets smaller before adjusting the size of the text and images. When it does adjust the size of the the text and image it seems to do it a way that's a lot more asthetically pleasing. Once the screen size hits 960px wide I'm going to use media queries to set flexbox to block. However I'd like the text and images to adjust the same was the originally between 1440px and 960px. I've recorded a video to show what I mean - https://youtu.be/1pKq_UW-3Hk
And here's my code...
.section3-h1 {
font-size: 3.125rem;
font-family: "Roboto";
}
button {
width: 176px;
height: 47px;
background: #6442ff;
color: #ffffff;
font-family: "Roboto";
font-size: 12px;
line-height: 18px;
align-items: center;
border: none;
}
.section2-head {
margin: 150px;
margin-top: 50px;
margin-bottom: 50px;
display: flex;
flex-flow: row wrap-reverse;
}
.section2-text {
max-width: 537px;
margin-right: 74px;
}
.button {
margin-top: 60px;
}
.section3-head {
margin: 150px;
margin-top: 50px;
margin-bottom: 50px;
display: flex;
flex-flow: row wrap;
}
.section3-text {
max-width: 537px;
margin-left: 74px;
font-family: "Roboto";
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="style.css">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght#400;700&display=swap" rel="stylesheet">
<title>Document</title>
</head>
<body>
<section id="section2">
<header class="section2-head">
<div class="section2-text">
<h1 class="section2-h1"> Lorem ipsum dolor sit ame.
</h1>
<p>Morbi sit amet varius nunc, blandit vulputate mi. Nulla a lobortis magna. Ut bibendum, augue quis lacinia tempus, justo ligula tincidunt ligula, eu bibendum ante libero imperdiet magna. Mauris vel consectetur arcu. Pellentesque risus tortor, lacinia nec dictum a, sagittis quis turpis. Aliquam dolor ante, rhoncus nec congue at, dictum vitae eros. Integer nec viverra leo. Curabitur blandit pretium rhoncus. In ut egestas elit</p>
<button class="button">READ MORE</button>
</div>
<img src="https://via.placeholder.com/528x396" alt="" class="section2-img">
</header>
</section>
<section id="section3">
<header class="section3-head">
<img src="https://via.placeholder.com/528x396" alt="" class="section3-img">
<div class="section3-text">
<h1 class="section3-h1"> Lorem ipsum dolor sit ame.
</h1>
<p>Morbi sit amet varius nunc, blandit vulputate mi. Nulla a lobortis magna. Ut bibendum, augue quis lacinia tempus, justo ligula tincidunt ligula, eu bibendum ante libero imperdiet magna. Mauris vel consectetur arcu. Pellentesque risus tortor, lacinia nec dictum a, sagittis quis turpis. Aliquam dolor ante, rhoncus nec congue at, dictum vitae eros. Integer nec viverra leo. Curabitur blandit pretium rhoncus. In ut egestas elit</p>
<button class="button">READ MORE</button>
</div>
</header>
</section>
</body>
</html>
Here is your code completely rewritten, removing all of the max-widths and unnecessary CSS. I added the media query for desktop styles as well.
button {
width: 176px;
height: 47px;
background: #6442ff;
color: #ffffff;
font-family: "Roboto";
font-size: 12px;
line-height: 18px;
align-items: center;
border: none;
}
section {
margin: 0 20px;
max-width: 1170px;
padding: 50px 0;
}
section header {
display: flex;
flex-direction: column;
}
section header .text {
margin: 30px 0 0 0;
}
section header img {
display: block;
width: 100%;
height: auto;
}
section.reverse header .text {
order: 2;
}
section.reverse header img {
order: 1;
}
#media (min-width: 992px) {
section {
margin: 40px auto;
}
section header {
flex-direction: row;
flex-wrap: nowrap;
}
section header .text {
flex: 0 0 calc(50% - 30px);
margin: 0 0 0 30px;
}
section header img {
flex: 0 0 calc(50% - 30px);
margin: 0 30px 0 0;
}
section.reverse header .text {
margin: 0 30px 0 0;
order: 1;
}
section.reverse header img {
order: 2;
margin: 0 0 0 30px;
}
}
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght#400;700&display=swap" rel="stylesheet">
<div class="container">
<section id="section2" class="reverse">
<header class="section2-head">
<div class="section2-text text">
<h1 class="section2-h1"> Lorem ipsum dolor sit ame.
</h1>
<p>Morbi sit amet varius nunc, blandit vulputate mi. Nulla a lobortis magna. Ut bibendum, augue quis lacinia tempus, justo ligula tincidunt ligula, eu bibendum ante libero imperdiet magna. Mauris vel consectetur arcu. Pellentesque risus tortor, lacinia
nec dictum a, sagittis quis turpis. Aliquam dolor ante, rhoncus nec congue at, dictum vitae eros. Integer nec viverra leo. Curabitur blandit pretium rhoncus. In ut egestas elit</p>
<button class="button">READ MORE</button>
</div>
<img src="https://via.placeholder.com/528x396" alt="" class="section2-img">
</header>
</section>
</div>
<div class="container">
<section id="section3">
<header class="section3-head">
<img src="https://via.placeholder.com/528x396" alt="" class="section3-img">
<div class="section3-text text">
<h1 class="section3-h1"> Lorem ipsum dolor sit ame.
</h1>
<p>Morbi sit amet varius nunc, blandit vulputate mi. Nulla a lobortis magna. Ut bibendum, augue quis lacinia tempus, justo ligula tincidunt ligula, eu bibendum ante libero imperdiet magna. Mauris vel consectetur arcu. Pellentesque risus tortor, lacinia
nec dictum a, sagittis quis turpis. Aliquam dolor ante, rhoncus nec congue at, dictum vitae eros. Integer nec viverra leo. Curabitur blandit pretium rhoncus. In ut egestas elit</p>
<button class="button">READ MORE</button>
</div>
</header>
</section>
</div>
I've observed that you have written so much redundant code in here. I have reframed you code.
please refer the code below. I have changed all classes and structure to reduce stylesheet overhead.
* {
font-family: "Roboto";
}
.button {
width: 176px;
height: 47px;
background: #6442ff;
color: #ffffff;
font-family: "Roboto";
font-size: 12px;
line-height: 18px;
align-items: center;
border: none;
margin-top: 60px;
}
.container {
width: 90%;
margin: 0 auto;
}
.flexbox {
display: flex;
flex-grow: 1;
flex-basis: 0;
}
.flexbox * {
width: 100%;
}
.marr74 {
margin-right: 74px;
}
.marl74 {
margin-left: 74px;
}
.flex-image img {
width: 100%;
}
.heading {
font-size: 3.125rem;
}
#media only screen and (max-width: 764px){
.flexbox {
flex-direction: column;
}
}
And here is HTML
<section>
<div class="container">
<div class="flexbox">
<div class="flex-content marr74">
<p class="heading">Lorem ipsum dolor sit ame. </p>
<p>Morbi sit amet varius nunc, blandit vulputate mi. Nulla a lobortis magna. Ut bibendum, augue quis lacinia tempus, justo ligula tincidunt ligula, eu bibendum ante libero imperdiet magna. Mauris vel consectetur arcu. Pellentesque risus tortor, lacinia nec dictum a, sagittis quis turpis. Aliquam dolor ante, rhoncus nec congue at, dictum vitae eros. Integer nec viverra leo. Curabitur blandit pretium rhoncus. In ut egestas elit</p>
READ MORE
</div>
<div class="flex-image"><img src="https://via.placeholder.com/528x396" alt="" class="section2-img"></div>
</div>
<div class="flexbox">
<div class="flex-image"><img src="https://via.placeholder.com/528x396" alt="" class="section2-img"></div>
<div class="flex-content marl74">
<p class="heading">Lorem ipsum dolor sit ame. </p>
<p>Morbi sit amet varius nunc, blandit vulputate mi. Nulla a lobortis magna. Ut bibendum, augue quis lacinia tempus, justo ligula tincidunt ligula, eu bibendum ante libero imperdiet magna. Mauris vel consectetur arcu. Pellentesque risus tortor, lacinia nec dictum a, sagittis quis turpis. Aliquam dolor ante, rhoncus nec congue at, dictum vitae eros. Integer nec viverra leo. Curabitur blandit pretium rhoncus. In ut egestas elit</p>
READ MORE
</div>
</div>
</div>
</section>
Also note that you should not use more than one h1 on one single page. This affects the SEO of your website. Instead use p or similar element with font-size to achieve large fonts.

Adding navbar to centred elements using display property

I am trying to centre and overall set elements using css display property but i encountered a problem.
Once i added a navbar as an element whole structure got changed it's place.
Here is the code before i added navbar:
body {
display: flex;
justify-content: center;
}
.content {
display: inline-flex;
width: 600px;
height: 100%;
border-width: 1px;
justify-content: center;
}
.nav {
width: 100%;
height: 100px;
border-width: 1px;
background-color: #000000;
display: block;
}
.menu {
display: inline-block;
width: 200px;
height: 100%;
background-color: #3F4E62;
}
.article {
display: inline-block;
width: 380px;
height: 100%;
background-color: #dddddd;
}
.item{
color: #FFFFFF;
font-family: Georgia;
display: block;
}
<div class="content"><div class="menu"><a class="item">MENU ITEM</a><a class="item">MENU ITEM</a><a class="item">MENU ITEM</a></div><div class="article">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean iaculis non eros pellentesque
commodo. Phasellus elit mauris, ultricies ac sem volutpat, efficitur convallis nibh. Mauris rutrum
odio nec justo rutrum, sit amet tristique sapien tristique. Nullam ac urna eget tortor suscipit blandit.
Maecenas pharetra faucibus odio quis feugiat. Curabitur a commodo arcu, a pellentesque lorem.
Nulla facilisi. Nullam augue metus, scelerisque sed pulvinar at, fermentum sit amet arcu. Morbi
lobortis suscipit porttitor. In vel tristique lorem, vitae pulvinar sapien. Nullam pretium imperdiet
nibh, eu bibendum arcu egestas ac. Vestibulum faucibus fringilla justo. Nam facilisis
elementum ex, ut fermentum leo feugiat vulputate. Ut molestie, enim ac faucibus mollis, est turpis
varius lectus, at sollicitudin erat ligula vitae tortor. Ut tincidunt sed sem in sodales. Cras tincidunt
ligula diam, quis volutpat quam cursus nec.
</div></div>
Navbar was supposed to be a line across whole window but it got stuck inline with elements from div with class="content".
Here is the code when i added navbar:
body {
display: flex;
justify-content: center;
}
.content {
display: inline-flex;
width: 600px;
height: 100%;
border-width: 1px;
justify-content: center;
}
.nav {
width: 100%;
height: 100px;
border-width: 1px;
background-color: #000000;
display: block;
}
.menu {
display: inline-block;
width: 200px;
height: 100%;
background-color: #3F4E62;
}
.article {
display: inline-block;
width: 380px;
height: 100%;
background-color: #dddddd;
}
.item{
color: #FFFFFF;
font-family: Georgia;
display: block;
}
<div class="nav">Navbar</div>
<div class="content"><div class="menu"><a class="item">MENU ITEM</a><a class="item">MENU ITEM</a><a class="item">MENU ITEM</a></div><div class="article">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean iaculis non eros pellentesque
commodo. Phasellus elit mauris, ultricies ac sem volutpat, efficitur convallis nibh. Mauris rutrum
odio nec justo rutrum, sit amet tristique sapien tristique. Nullam ac urna eget tortor suscipit blandit.
Maecenas pharetra faucibus odio quis feugiat. Curabitur a commodo arcu, a pellentesque lorem.
Nulla facilisi. Nullam augue metus, scelerisque sed pulvinar at, fermentum sit amet arcu. Morbi
lobortis suscipit porttitor. In vel tristique lorem, vitae pulvinar sapien. Nullam pretium imperdiet
nibh, eu bibendum arcu egestas ac. Vestibulum faucibus fringilla justo. Nam facilisis
elementum ex, ut fermentum leo feugiat vulputate. Ut molestie, enim ac faucibus mollis, est turpis
varius lectus, at sollicitudin erat ligula vitae tortor. Ut tincidunt sed sem in sodales. Cras tincidunt
ligula diam, quis volutpat quam cursus nec.
</div></div>
Leave the body tag and add another div class="main-container"> name it whatever you want with the following style. You're missing the flex-flow: or flex-wrap so the elements are not wrapping and you basically need them to wrap.
.main-container {
display: flex;
flex-flow: row wrap;
justify-content: center;
}
Here check this:
.main-container {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.content {
display: inline-flex;
width: 600px;
height: 100%;
border-width: 1px;
justify-content: center;
}
.nav {
width: 100%;
height: 100px;
border-width: 1px;
background-color: #000000;
display: block;
}
.menu {
display: inline-block;
width: 200px;
height: 100%;
background-color: #3f4e62;
}
.article {
display: inline-block;
width: 380px;
height: 100%;
background-color: #dddddd;
}
.item {
color: #ffffff;
font-family: Georgia;
display: block;
}
<div class="main-container">
<div class="nav">Navbar</div>
<div class="content">
<div class="menu"><a class="item">MENU ITEM</a><a class="item">MENU ITEM</a><a class="item">MENU ITEM</a></div>
<div class="article">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean iaculis non eros pellentesque commodo. Phasellus elit mauris, ultricies ac sem volutpat, efficitur convallis nibh. Mauris rutrum odio nec justo rutrum, sit amet tristique sapien tristique.
Nullam ac urna eget tortor suscipit blandit. Maecenas pharetra faucibus odio quis feugiat. Curabitur a commodo arcu, a pellentesque lorem. Nulla facilisi. Nullam augue metus, scelerisque sed pulvinar at, fermentum sit amet arcu. Morbi lobortis suscipit
porttitor. In vel tristique lorem, vitae pulvinar sapien. Nullam pretium imperdiet nibh, eu bibendum arcu egestas ac. Vestibulum faucibus fringilla justo. Nam facilisis elementum ex, ut fermentum leo feugiat vulputate. Ut molestie, enim ac faucibus
mollis, est turpis varius lectus, at sollicitudin erat ligula vitae tortor. Ut tincidunt sed sem in sodales. Cras tincidunt ligula diam, quis volutpat quam cursus nec.
</div>
</div>
</div>

How to create a list style for an article

I'm trying to split an article into a list format such that it shows the title, the image, and then description. Let's say I have an article title: 3 Ways to Make Money, then I have the article in a list, like so:
(sub-title) 3. Sleep All Day (then an image, followed by a little description),
(sub-title) 2. Eat Well (then an image, followed by a little description) and
(sub-title) 1. Watch TV (then an image, followed by a little description)... such that users will click on the next or previous button to see the next or previous list respectively. See sample image for better understanding
So far, I've been able to come up with this:
.logg-list {
overflow: hidden;
margin-top: 5px;
float: left;
width: 619px;
}
.logg-list-controls {width: 100%;
top: 1px;
z-index: 2;
cursor: pointer;
margin-bottom: 5px;
}
a.logg-list-nav-left {
float: left;
background-color: #042a54;
color: #fff;
font-size: 14px;
line-height: 38px;
width: 88px;
height: 40px;
font-style: normal;
font-weight: 400;
text-align: center;
text-decoration: none;
}
a.logg-list-nav-right {
float: right;
background-color: #042a54;
color: #fff;
font-size: 14px;
line-height: 38px;
width: 88px;
overflow: hidden;
font-style: normal;
font-weight: 400;
text-align: center;
text-decoration: none;
}
.logg-list-content {
width: 6190px;
max-height: 600px;
overflow: hidden;
}
.list-number-title {
position: relative;
top: -30px;
text-align: center;
width: 100%;
display: inline-block;
overflow: hidden;
}
.list-item-title {
display: inline-block;
font-weight: 700;
font-size: 22px;
margin-top: 0;
margin-bottom: 0;
overflow: hidden;
}
.list-image {
width: 619px;
height: 400px;
overflow: hidden;
}
.list-description {
margin-top: 22px;
display: block;
overflow: hidden;
width: 619px;
height: auto;
float: left;
}
<div class="logg-list">
<div class="logg-list-controls">
<a class="logg-list-nav-left" href="#" style="cursor: pointer;">
<i class="fa fa-caret-left"></i> Prev
</a>
<a class="logg-list-nav-right" href="#" style="cursor: pointer;">
Next <i class="fa fa-caret-right"></i>
</a>
</div>
<div class="logg-list-content pull-left">
<div class="list-number-title">
<h2 class="list-item-title">10. Longer Title made from long poster</h2>
</div>
<div class="list-image">
<img src="http://placehold.it/619x400.png?text=no+image" alt="Default Image" itemprop="image">
</div>
<div class="list-description">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna. Nunc viverra imperdiet enim. Fusce est.
<p>Vivamus a tellus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci. Aenean nec lorem.</p>
<p>In porttitor. Donec laoreet nonummy augue. Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.</p>
</div>
<!-- Another List Here -->
<div class="list-number-title">
<h2 class="list-item-title">9. He belongs to you.</h2>
</div>
<div class="list-image">
<img src="http://placehold.it/619x400.png?text=no+image" alt="Default Image" itemprop="image">
</div>
<div class="list-description">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna. Nunc viverra imperdiet enim. Fusce est.
<p>Vivamus a tellus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci. Aenean nec lorem.</p>
<p>In porttitor. Donec laoreet nonummy augue. Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.</p>
</div>
</div>
</div>
Here's my challenge now....
The subtitles are not displaying.
Some descriptions may be long, and if I remove the max-height value in the .list-description, the next image shows up.
I would remove the top positioning on .list-number-title, that will show your titles. Also, I'd remove the width being set as 6190px on .logg-list-content. Set it to 100% and the example shows correctly.
Regards the max height - if you want to limit the size of the description this should be set on .list-description and not .logg-list-content. A better way of doing that would be to limit the description to a certain number of characters, rather than forcing a max height.
.logg-list {
overflow: hidden;
margin-top: 5px;
float: left;
width: 619px;
}
.logg-list-controls {width: 100%;
top: 1px;
z-index: 2;
cursor: pointer;
margin-bottom: 5px;
}
a.logg-list-nav-left {
float: left;
background-color: #042a54;
color: #fff;
font-size: 14px;
line-height: 38px;
width: 88px;
height: 40px;
font-style: normal;
font-weight: 400;
text-align: center;
text-decoration: none;
}
a.logg-list-nav-right {
float: right;
background-color: #042a54;
color: #fff;
font-size: 14px;
line-height: 38px;
width: 88px;
overflow: hidden;
font-style: normal;
font-weight: 400;
text-align: center;
text-decoration: none;
}
.logg-list-content {
width: 100%;
overflow: hidden;
}
.list-number-title {
position: relative;
text-align: center;
width: 100%;
display: inline-block;
overflow: hidden;
}
.list-item-title {
display: inline-block;
font-weight: 700;
font-size: 22px;
margin-top: 0;
margin-bottom: 0;
overflow: hidden;
}
.list-image {
width: 619px;
height: 400px;
overflow: hidden;
}
.list-description {
margin-top: 22px;
display: block;
overflow: hidden;
width: 619px;
max-height: 100px;
float: left;
}
<div class="logg-list">
<div class="logg-list-controls">
<a class="logg-list-nav-left" href="#" style="cursor: pointer;">
<i class="fa fa-caret-left"></i> Prev
</a>
<a class="logg-list-nav-right" href="#" style="cursor: pointer;">
Next <i class="fa fa-caret-right"></i>
</a>
</div>
<div class="logg-list-content pull-left">
<div class="list-number-title">
<h2 class="list-item-title">10. Longer Title made from long poster</h2>
</div>
<div class="list-image">
<img src="http://placehold.it/619x400.png?text=no+image" alt="Default Image" itemprop="image">
</div>
<div class="list-description">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna. Nunc viverra imperdiet enim. Fusce est.
<p>Vivamus a tellus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci. Aenean nec lorem.</p>
<p>In porttitor. Donec laoreet nonummy augue. Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.</p>
</div>
<!-- Another List Here -->
<div class="list-number-title">
<h2 class="list-item-title">9. He belongs to you.</h2>
</div>
<div class="list-image">
<img src="http://placehold.it/619x400.png?text=no+image" alt="Default Image" itemprop="image">
</div>
<div class="list-description">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna. Nunc viverra imperdiet enim. Fusce est.
<p>Vivamus a tellus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci. Aenean nec lorem.</p>
<p>In porttitor. Donec laoreet nonummy augue. Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.</p>
</div>
</div>
</div>

Place a div in bottom right corner inside a column

I'm trying to align a div at the bottom right corner inside a specific column, but all instead it aligns at the bottom right corner of the main parent.
https://jsfiddle.net/jonnijonnason/L9vg468g/
If you check the fiddle, I want it to align beneath the image.
HTML
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width" />
<title>Arbetsprov | Baldvin Haraldsson</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
</head>
<body>
<div class="page">
<div class="row">
<div class="item">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed congue enim sed tristique interdum. Integer id lectus et risus pulvinar ornare. Donec congue tortor non risus ullamcorper vestibulum. Nullam in hendrerit tellus. Vestibulum lorem nulla, maximus non pretium a, tincidunt id quam. Donec quis sollicitudin urna, sed sagittis purus. Pellentesque sapien libero, blandit a nunc in, iaculis viverra ipsum</p>
</div>
<div class="item">
<p>Nullam maximus pretium arcu at sodales. Sed id venenatis ante. Nullam sollicitudin id nisl quis dictum. Duis imperdiet diam at nibh laoreet egestas. Integer volutpat, dolor a pulvinar mollis, nisl lorem hendrerit tortor, sit amet posuere ante odio quis lorem. Vivamus luctus sem quis eros elementum pretium. Sed facilisis sem at velit euismod pretium. Maecenas posuere sapien elit, at accumsan orci pretium non. Suspendisse id sem nisi.</p>
</div>
<div class="item">
<H3>Image</H3>
<img src="https://upload.wikimedia.org/wikipedia/commons/8/88/Stockholm_Port.jpg" width="140px" height = "140px" />
Donec bibendum nibh a odio venenatis, vel ultricies turpis varius. Vestibulum varius sollicitudin rutrum. Nam eleifend ac nisl non aliquet. Donec vel scelerisque sapien. Donec ultrices vel neque ut bibendum. Suspendisse bibendum, ex sed congue dapibus, nibh magna malesuada dolor, at scelerisque dolor ex quis lectus. Curabitur rhoncus elit efficitur hendrerit malesuada. Morbi condimentum convallis laoreet.
<div class = "foo">Read More</div>
</div>
</div>
</div>
</body>
</html>
CSS
#charset "UTF-8";
.item {
width: 33%;
background: rgba(0, 0, 0, 0.1);
display: table-cell;
}
.row {
border: 1px solid red;
display: table;
border-spacing: 20px;
}
.page {
max-width: 900px;
margin: 0px auto 0px auto;
position: relative;
background-color: #fff;
}
img {
float: right;
margin: 0 0 10px 10px;
padding: 10px;
}
.foo {
font-family: Impact, Haettenschweiler, "Franklin Gothic Bold", Charcoal, "Helvetica Inserat", "Bitstream Vera Sans Bold", "Arial Black", "sans serif";
color: #fff;
text-align: center;
vertical-align: middle;
line-height: 50px;
background-color: #4a4a4a;
height: 50px;
width: 162px;
position: absolute;
bottom: 0;
right: 0;
}
Add to <div class="item"> column a position:relative;
The button inside has an absolute position so it is relative to the next parent element with relative (or absolute) positioning.
Also, to make it not overlap the text you can also set padding-bottom
.item.contains-button {
position:relative;
padding-bottom:60px;
}
Your updated JSFiddle
What you need to do is just add Position: relative; to the last column. This will make Read more div to be at bottom right corner of the direct parent DIV instead of the main DIV.
Updated jsFiddle: https://jsfiddle.net/L9vg468g/4/
HTML:
<body>
<div class="page">
<div class="row">
<div class="item">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed congue enim sed tristique interdum. Integer id lectus et risus pulvinar ornare. Donec congue tortor non risus ullamcorper vestibulum. Nullam in hendrerit tellus. Vestibulum lorem nulla, maximus non pretium a, tincidunt id quam. Donec quis sollicitudin urna, sed sagittis purus. Pellentesque sapien libero, blandit a nunc in, iaculis viverra ipsum</p>
</div>
<div class="item">
<p>Nullam maximus pretium arcu at sodales. Sed id venenatis ante. Nullam sollicitudin id nisl quis dictum. Duis imperdiet diam at nibh laoreet egestas. Integer volutpat, dolor a pulvinar mollis, nisl lorem hendrerit tortor, sit amet posuere ante odio quis lorem. Vivamus luctus sem quis eros elementum pretium. Sed facilisis sem at velit euismod pretium. Maecenas posuere sapien elit, at accumsan orci pretium non. Suspendisse id sem nisi.</p>
</div>
<div class="item lastcol">
<H3>Image</H3>
<img src="https://upload.wikimedia.org/wikipedia/commons/8/88/Stockholm_Port.jpg" width="140px" height = "140px" />
Donec bibendum nibh a odio venenatis, vel ultricies turpis varius. Vestibulum varius sollicitudin rutrum. Nam eleifend ac nisl non aliquet. Donec vel scelerisque sapien. Donec ultrices vel neque ut bibendum. Suspendisse bibendum, ex sed congue dapibus, nibh magna malesuada dolor, at scelerisque dolor ex quis lectus. Curabitur rhoncus elit efficitur hendrerit malesuada. Morbi condimentum convallis laoreet.
<div class = "foo">Read More</div>
</div>
</div>
</div>
</body>
CSS:
#charset "UTF-8";
.item {
width: 33%;
background: rgba(0, 0, 0, 0.1);
display: table-cell;
position: relative;
}
.item.lastcol {
position: relative;
}
.row {
border: 1px solid red;
display: table;
border-spacing: 20px;
}
.page {
max-width: 900px;
margin: 0px auto 0px auto;
position: relative;
background-color: #fff;
}
img {
float: right;
margin: 0 0 10px 10px;
padding: 10px;
}
.foo {
font-family: Impact, Haettenschweiler, "Franklin Gothic Bold", Charcoal, "Helvetica Inserat", "Bitstream Vera Sans Bold", "Arial Black", "sans serif";
color: #fff;
text-align: center;
vertical-align: middle;
line-height: 50px;
background-color: #4a4a4a;
height: 50px;
width: 162px;
position: absolute;
bottom: 0;
right: 0;
}
As you have placed other two columns description inside paragraph tag, you can keep third description also inside a paragraph and it can be achievable by using css flexbox if your browser support is IE10 +.
Updated code below.
.item {
width: 33%;
background: rgba(0, 0, 0, 0.1);
display: table-cell;
display: flex;
flex-direction: column;
}
.row {
border: 1px solid red;
display: flex;
flex-direction: row;
flex-wrap: wrap;
border-spacing: 20px;
}
.page {
max-width: 900px;
margin: 0px auto 0px auto;
position: relative;
background-color: #fff;
}
img {
float: right;
margin: 0 0 10px 10px;
padding: 10px;
}
.foo {
font-family: Impact, Haettenschweiler, "Franklin Gothic Bold", Charcoal, "Helvetica Inserat", "Bitstream Vera Sans Bold", "Arial Black", "sans serif";
color: #fff;
text-align: center;
vertical-align: middle;
line-height: 50px;
background-color: #4a4a4a;
height: 50px;
width: 162px;
position: relative;
bottom: 0;
right: 0;
}
.item h3 {
order: 1;
}
.item img {order: 2;}
.item div {order: 3;}
.item p {order: 4;}
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width" />
<title>Arbetsprov | Baldvin Haraldsson</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
</head>
<body>
<div class="page">
<div class="row">
<div class="item">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed congue enim sed tristique interdum. Integer id lectus et risus pulvinar ornare. Donec congue tortor non risus ullamcorper vestibulum. Nullam in hendrerit tellus. Vestibulum lorem nulla, maximus non pretium a, tincidunt id quam. Donec quis sollicitudin urna, sed sagittis purus. Pellentesque sapien libero, blandit a nunc in, iaculis viverra ipsum</p>
</div>
<div class="item">
<p>Nullam maximus pretium arcu at sodales. Sed id venenatis ante. Nullam sollicitudin id nisl quis dictum. Duis imperdiet diam at nibh laoreet egestas. Integer volutpat, dolor a pulvinar mollis, nisl lorem hendrerit tortor, sit amet posuere ante odio quis lorem. Vivamus luctus sem quis eros elementum pretium. Sed facilisis sem at velit euismod pretium. Maecenas posuere sapien elit, at accumsan orci pretium non. Suspendisse id sem nisi.</p>
</div>
<div class="item lastcol">
<H3>Image</H3>
<img src="https://upload.wikimedia.org/wikipedia/commons/8/88/Stockholm_Port.jpg" width="140px" height = "140px" />
<p>Donec bibendum nibh a odio venenatis, vel ultricies turpis varius. Vestibulum varius sollicitudin rutrum. Nam eleifend ac nisl non aliquet. Donec vel scelerisque sapien. Donec ultrices vel neque ut bibendum. Suspendisse bibendum, ex sed congue dapibus, nibh magna malesuada dolor, at scelerisque dolor ex quis lectus. Curabitur rhoncus elit efficitur hendrerit malesuada. Morbi condimentum convallis laoreet.</p>
<div class = "foo">Read More</div>
</div>
</div>
</div>
</body>
</html>