I would like to center correctly my title Learn About Us like for the title What we do, because there is a lag with the picture, I think?
I don't understand how to center like this example:
Here, the titles are aligned correctly.
I thank you in advance for your help and your time.
h2 {
font-size: 2.5rem;
color: rgb(28, 19, 37);
margin: 0;
}
p {
color: rgb(134, 134, 134);
margin: 1rem 0;
line-height: 1.5;
}
button {
outline: none;
border: none;
border-radius: 0.25rem;
background: rgb(28, 19, 37);
color: #F7CAC9;
font-size: 1rem;
letter-spacing: 0.5px;
text-decoration: none;
padding: 1rem 1.5rem;
}
.container {
display: flex;
font-family: sans-serif;
max-width: 1000px;
margin: 2rem auto;
}
.container img {
height: 350px;
margin: 1rem;
}
.section-header p {
position: relative;
}
.section-header p::after,
.section-header p::before {
position: absolute;
content: "";
height: 2px;
width: 35px;
background: #F7CAC9;
z-index: -1;
}
.section-header p::after {
top: 11px;
margin: 0 10px;
}
.section-header p::before {
top: 11px;
margin-left: -45px;
}
.service .section-header {
width: 100%;
text-align: center;
}
<div class="about">
<div class="container">
<img src="https://zupimages.net/up/21/21/54ov.png" alt="Image">
<div class="content">
<div class="section-header">
<p>Learn About Us</p>
<h2>Welcome to Yooga</h2>
</div>
<div class="about-text">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus nec pretium mi. Curabitur facilisis
ornare
velit non vulputate. Aliquam metus tortor, auctor id gravida condimentum, viverra quis sem.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus nec pretium mi. Curabitur facilisis
ornare
velit non vulputate. Aliquam metus tortor, auctor id gravida condimentum, viverra quis sem. Curabitur non
nisl
nec nisi scelerisque maximus.
</p>
<button>Learn More</button>
</div>
</div>
</div>
</div>
<!-- About End -->
<br />
<!-- Service Start -->
<div class="service">
<div class="container">
<div class="section-header">
<p>What we do</p>
<h2>Yoga For Health</h2>
</div>
</div>
</div>
Since you have added -45px margin-left for .section-header p::before, you need to add +45px margin-left to .content .section-header p, to cancel out the effect.
h2 {
font-size: 2.5rem;
color: rgb(28, 19, 37);
margin: 0;
}
p {
color: rgb(134, 134, 134);
margin: 1rem 0;
line-height: 1.5;
}
button {
outline: none;
border: none;
border-radius: 0.25rem;
background: rgb(28, 19, 37);
color: #F7CAC9;
font-size: 1rem;
letter-spacing: 0.5px;
text-decoration: none;
padding: 1rem 1.5rem;
}
.container {
display: flex;
font-family: sans-serif;
max-width: 1000px;
margin: 2rem auto;
}
.container img {
height: 350px;
margin: 1rem;
}
.section-header p {
position: relative;
}
.content .section-header p{
margin-left: 45px;
}
.section-header p::after,
.section-header p::before {
position: absolute;
content: "";
height: 2px;
width: 35px;
background: #F7CAC9;
z-index: -1;
}
.section-header p::after {
top: 11px;
margin: 0 10px;
}
.section-header p::before {
top: 11px;
margin-left: -45px;
}
.service .section-header {
width: 100%;
text-align: center;
}
<div class="about">
<div class="container">
<img src="https://zupimages.net/up/21/21/54ov.png" alt="Image">
<div class="content">
<div class="section-header">
<p>Learn About Us</p>
<h2>Welcome to Yoga</h2>
</div>
<div class="about-text">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus nec pretium mi. Curabitur facilisis ornare velit non vulputate. Aliquam metus tortor, auctor id gravida condimentum, viverra quis sem.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus nec pretium mi. Curabitur facilisis ornare velit non vulputate. Aliquam metus tortor, auctor id gravida condimentum, viverra quis sem. Curabitur non nisl nec nisi scelerisque maximus.
</p>
<button>Learn More</button>
</div>
</div>
</div>
</div>
<!-- About End -->
<br />
<!-- Service Start -->
<div class="service">
<div class="container">
<div class="section-header">
<p>What we do</p>
<h2>Yoga For Health</h2>
</div>
</div>
</div>
Related
I'm new at this. I'm not sure what I'm doing wrong. I've tried both the absolute and relative position but I can't get the footer to go at the bottom of the page. I also don't want the fixed option. Can anyone tell what's wrong with it?
<!DOCTYPE html>
<html>
<head>
<title>after hours</title>
<link href="style.css" type="text/css" rel="stylesheet">
</head>
<body>
<div id="banner">
<div class="content">
<h1>as always <br> at this hour </h1>
<h1 class="maroon">time means <br> nothing</h1>
</div>
</div>
<div class="nav">
home
about
blog
portfolio
</div>
<div id="main">
<div class="about">
<p>Aenean ornare velit lacus, ac varius enim ullamcorper eu. Proin aliquam facilisis ante interdum congue. Integer mollis, nisl amet convallis, porttitor magna ullamcorper, amet egestas mauris. Ut magna finibus nisi nec lacinia. Nam maximus erat id euismod egestas. Pellentesque sapien ac quam. Lorem ipsum dolor sit nullam.</p>
</div>
<div class="content">
<p>Aenean ornare velit lacus, ac varius enim ullamcorper eu. Proin aliquam facilisis ante interdum congue. Integer mollis, nisl amet convallis, porttitor magna ullamcorper, amet egestas mauris. Ut magna finibus nisi nec lacinia. Nam maximus erat id euismod egestas. Pellentesque sapien ac quam. Lorem ipsum dolor sit nullam.</p>
<div class="rectangle">
<p>This is a rectangle.</p>
</div>
<div class="rectangle">
<p>This is a rectangle too.</p>
</div>
<div class="rectangle">
<p>This a rectangle as well.</p>
</div>
</div>
</div>
<footer>
<p>Aenean ornare velit lacus, ac varius enim ullamcorper eu. Proin aliquam facilisis ante interdum congue. Integer mollis, nisl amet convallis, porttitor magna ullamcorper, amet egestas mauris. Ut magna finibus nisi nec lacinia. Nam maximus erat id euismod egestas. Pellentesque sapien ac quam. Lorem ipsum dolor sit nullam.</p>
</footer>
</body>
</html>
This is the separate CSS code. I'm not sure if the footer should be a class or it can simply be a tag.
* {
margin: 0;
padding: 0;
}
* {
box-sizing: border-box;
}
body {
font-family: helvetica;
line-height: 25px;
font-size: 15px;
letter-spacing: 0.5px;
}
#banner {
background: url(imgs/1.jpg);
background-size: cover;
width: 100%;
height: 660px;
position: absolute;
}
#banner .content h1 {
text-align: center;
position: absolute;
top: 54%;
left: 42.6%;
padding: 30 30 60 30;
color: #d6d6d6;
font-size: 30px;
font-family: futura;
letter-spacing: 4px;
line-height: 30px;
/*
border: 1.5px solid white;
width: 260px;
height: 80px;
*/
}
#banner .content h1.maroon {
padding-top: 70px;
color: firebrick;
}
.nav {
position: relative;
top: 660px;
background-color: black;
width: 100%;
height: 60px;
text-align: center;
padding: 20px 0px;
margin-bottom: 30px;
}
.nav a {
position: relative;
text-transform: uppercase;
text-align: center;
color: white;
font-family: roboto;
font-weight: normal;
text-decoration: none;
font-size: 13px;
letter-spacing: 5px;
padding: 22px 40px;
display: inline;
}
.nav a:hover {
color: firebrick;
}
#main {
position: relative;
margin: 0 auto;
top: 670px;
width: 80%;
padding: 20px;
}
.about {
float: right;
width: 30%;
padding: 10px;
}
.rectangle {
padding: 30px;
display: inline-block;
text-align: center;
width: 180px;
height: 200px;
}
.content {
float: left;
width: 60%;
padding: 10px;
}
footer {
position: absolute;
right: 0;
bottom: 0;
left: 0;
width: 100%;
padding: 30px;
margin: 0 auto;
height: 300px;
}
Position everything relative, unless you really need to use absolute.
See working snippet using your code.
* {
margin: 0;
padding: 0;
}
* {
box-sizing: border-box;
}
body {
font-family: helvetica;
line-height: 25px;
font-size: 15px;
letter-spacing: 0.5px;
position: relative;
}
#banner {
background: url(imgs/1.jpg);
background-size: cover;
width: 100%;
height: 660px;
position: relative;
}
#banner .content h1 {
text-align: center;
position: absolute;
top: 54%;
left: 42.6%;
padding: 30 30 60 30;
color: #d6d6d6;
font-size: 30px;
font-family: futura;
letter-spacing: 4px;
line-height: 30px;
}
#banner .content h1.maroon {
position: relative;
padding-top: 70px;
color: firebrick;
}
.nav {
position: relative;
background-color: black;
width: 100%;
height: 60px;
text-align: center;
padding: 20px 0px;
margin-bottom: 30px;
clear: both;
}
.nav a {
position: relative;
text-transform: uppercase;
text-align: center;
color: white;
font-family: roboto;
font-weight: normal;
text-decoration: none;
font-size: 13px;
letter-spacing: 5px;
padding: 22px 40px;
display: inline;
}
.nav a:hover {
color: firebrick;
clear: both;
}
#main {
position: relative;
margin: 0 auto;
width: 80%;
padding: 20px;
clear: both;
}
.about {
float: right;
width: 30%;
padding: 10px;
}
.rectangle {
padding: 30px;
display: inline-block;
text-align: center;
width: 180px;
height: 200px;
}
.content {
width: 60%;
padding: 10px;
}
footer {
position: relative;
width: 100%;
padding: 30px;
margin: 0 auto;
height: 300px;
border: 1px solid red;
}
<!DOCTYPE html>
<html>
<head>
<title>after hours</title>
<link href="style.css" type="text/css" rel="stylesheet">
</head>
<body>
<div id="banner">
<div class="content">
<h1>as always <br> at this hour </h1>
<h1 class="maroon">time means <br> nothing</h1>
</div>
</div>
<div class="nav">
home
about
blog
portfolio
</div>
<div id="main">
<div class="about">
<p>Aenean ornare velit lacus, ac varius enim ullamcorper eu. Proin aliquam facilisis ante interdum congue. Integer mollis, nisl amet convallis, porttitor magna ullamcorper, amet egestas mauris. Ut magna finibus nisi nec lacinia. Nam maximus erat id euismod egestas. Pellentesque sapien ac quam. Lorem ipsum dolor sit nullam.</p>
</div>
<div class="content">
<p>Aenean ornare velit lacus, ac varius enim ullamcorper eu. Proin aliquam facilisis ante interdum congue. Integer mollis, nisl amet convallis, porttitor magna ullamcorper, amet egestas mauris. Ut magna finibus nisi nec lacinia. Nam maximus erat id euismod egestas. Pellentesque sapien ac quam. Lorem ipsum dolor sit nullam.</p>
<div class="rectangle">
<p>This is a rectangle.</p>
</div>
<div class="rectangle">
<p>This is a rectangle too.</p>
</div>
<div class="rectangle">
<p>This a rectangle as well.</p>
</div>
</div>
</div>
<footer>
<p>Footer text in here</p>
</footer>
</body>
</html>
If all you want to do is put the div at the botton of the screen then add this to your css:
.footer{
position: absolute;
bottom: 0;
}
When you scroll the footer will also move though. If you want it to stay in the same location then make position: fixed
In your HTML you are closing </footer> instead of close </div>.
And give position: relative to the main parent div and apply
.footer {
position: absolute;
bottom: 0;
}
this will work.
remove position: relative; #main id css.
* {
margin: 0;
padding: 0;
}
* {
box-sizing: border-box;
}
body {
font-family: helvetica;
line-height: 25px;
font-size: 15px;
letter-spacing: 0.5px;
}
#banner {
background: url(imgs/1.jpg);
background-size: cover;
width: 100%;
height: 660px;
}
#banner .content h1 {
text-align: center;
position:relative;
top: 54%;
left: 42.6%;
padding: 30 30 60 30;
color: #d6d6d6;
font-size: 30px;
font-family: futura;
letter-spacing: 4px;
line-height: 30px;
/*
border: 1.5px solid white;
width: 260px;
height: 80px;
*/
}
#banner .content h1.maroon {
padding-top: 70px;
color: firebrick;
position:relative;
}
.nav {
top: 660px;
background-color: black;
width: 100%;
height: 60px;
text-align: center;
padding: 20px 0px;
margin-bottom: 30px;
}
.nav a {
position: relative;
text-transform: uppercase;
text-align: center;
color: white;
font-family: roboto;
font-weight: normal;
text-decoration: none;
font-size: 13px;
letter-spacing: 5px;
padding: 22px 40px;
display: inline;
}
.nav a:hover {
color: firebrick;
}
#main {
/* position: relative;*/
margin: 0 auto;
top: 670px;
width: 80%;
padding: 20px;
}
.about {
float: right;
width: 30%;
padding: 10px;
}
.rectangle {
padding: 30px;
display: inline-block;
text-align: center;
width: 180px;
height: 200px;
}
.content {
float: left;
width: 60%;
padding: 10px;
}
footer {
/* position: absolute;*/
float: left;
right: 0;
bottom: 0;
left: 0;
width: 100%;
padding: 30px;
margin: 0 auto;
height: 300px;
}
<!DOCTYPE html>
<html>
<head>
<title>after hours</title>
<link href="style.css" type="text/css" rel="stylesheet">
</head>
<body>
<div id="banner">
<div class="content">
<h1>as always <br> at this hour </h1>
<h1 class="maroon">time means <br> nothing</h1>
</div>
</div>
<div class="nav">
home
about
blog
portfolio
</div>
<div id="main">
<div class="about">
<p>Aenean ornare velit lacus, ac varius enim ullamcorper eu. Proin aliquam facilisis ante interdum congue. Integer mollis, nisl amet convallis, porttitor magna ullamcorper, amet egestas mauris. Ut magna finibus nisi nec lacinia. Nam maximus erat id euismod egestas. Pellentesque sapien ac quam. Lorem ipsum dolor sit nullam.</p>
</div>
<div class="content">
<p>Aenean ornare velit lacus, ac varius enim ullamcorper eu. Proin aliquam facilisis ante interdum congue. Integer mollis, nisl amet convallis, porttitor magna ullamcorper, amet egestas mauris. Ut magna finibus nisi nec lacinia. Nam maximus erat id euismod egestas. Pellentesque sapien ac quam. Lorem ipsum dolor sit nullam.</p>
<div class="rectangle">
<p>This is a rectangle.</p>
</div>
<div class="rectangle">
<p>This is a rectangle too.</p>
</div>
<div class="rectangle">
<p>This a rectangle as well.</p>
</div>
</div>
</div>
<footer>
<p>this is footer part <br/>Aenean ornare velit lacus, ac varius enim ullamcorper eu. Proin aliquam facilisis ante interdum congue. Integer mollis, nisl amet convallis, porttitor magna ullamcorper, amet egestas mauris. Ut magna finibus nisi nec lacinia. Nam maximus erat id euismod egestas. Pellentesque sapien ac quam. Lorem ipsum dolor sit nullam.</p>
</footer>
</body>
</html>
there is a box with text, at the right of the box there is an image
The box of text is have z index higher than image, so box of text look like in front of image
I used text-align center, to center all components inside div, and this is a must
Now I want the only text, only the text in box of text is align left
How can I achieve this?
.button-yellow, .button-red {
font: 16px AdobeCaslonPro;
text-decoration: none;
padding: 6px 12px 6px 12px;
border-right: 1px solid #333333;
border-bottom: 1px solid #333333;
border-radius: 4px;
moz-border-radius: 4px;
webkit-border-radius: 4px;
font-style: italic;
}
.button-yellow {
background-color: #ccb96b;
color: #430615;
}
.button-red {
background-color: #430615;
color: #ccb96b;
margin-top: -20px;
}
#section-welcome-content {
text-align: center;
}
#welcome-content{
width: 45%;
margin: 0 0 0 0 ;
}
#welcome-content-inner {
background-color: #ccb96b;
color: #430615;
padding: 50px;
z-index: 10;
position: relative;
}
#welcome-content p{
}
#crop {
width: 600px;
height: 500px;
overflow: hidden;
margin: 0 0 0 -50px ;
}
#crop img {
width: 800px;
height: 600px;
margin: -75px 0 0 -100px;
z-index: 1;
}
<section id="section-welcome-content" class="pad">
<div id="welcome-content" style=" display: inline-block; " >
<div id="welcome-content-inner" >
<p>
<h3 style="font-size: 1.5em; text-transform: uppercase;"> <i>Lorem ipsum</i> </h3>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris arcu sapien, dignissim id laoreet quis, sollicitudin sed dui. Mauris mauris ligula, hendrerit sed ligula vitae, viverra auctor eros. Duis rutrum dolor a felis elementum, eu facilisis justo sollicitudin.
<br><br>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris arcu sapien, dignissim id laoreet quis, sollicitudin sed dui. Mauris mauris ligula, hendrerit sed ligula vitae, viverra auctor eros. Duis rutrum dolor a felis elementum, eu facilisis justo sollicitudin.
<br><br><br>
Read more
</p>
</div>
<div>
</div>
<div>
</div>
</div>
<div id="crop" style=" display: inline-block; ">
<img src="http://media.caranddriver.com/images/media/51/2017-10best-lead-photo-672628-s-original.jpg" alt="" style=" "/>
</div>
</section>
Any help appreciated
My answer comprises of 2 scenarios so it can help you the way you want. So you can choose the best way you want. I have also included live example so you can easily check it .
1. For all text inside to be on left, which includes both heading and text. Add this css
/* For All Left */
#welcome-content-inner {
text-align: left;
}
.button-yellow,
.button-red {
font: 16px AdobeCaslonPro;
text-decoration: none;
padding: 6px 12px 6px 12px;
border-right: 1px solid #333333;
border-bottom: 1px solid #333333;
border-radius: 4px;
moz-border-radius: 4px;
webkit-border-radius: 4px;
font-style: italic;
}
.button-yellow {
background-color: #ccb96b;
color: #430615;
}
.button-red {
background-color: #430615;
color: #ccb96b;
margin-top: -20px;
}
#section-welcome-content {
text-align: center;
}
#welcome-content {
width: 45%;
margin: 0 0 0 0;
}
#welcome-content-inner {
background-color: #ccb96b;
color: #430615;
padding: 50px;
z-index: 10;
position: relative;
}
#welcome-content p {}
#crop {
width: 600px;
height: 500px;
overflow: hidden;
margin: 0 0 0 -50px;
}
#crop img {
width: 800px;
height: 600px;
margin: -75px 0 0 -100px;
z-index: 1;
}
/* For All Left */
#welcome-content-inner {
text-align: left;
}
<section id="section-welcome-content" class="pad">
<div id="welcome-content" style=" display: inline-block; ">
<div id="welcome-content-inner">
<p>
<h3 style="font-size: 1.5em; text-transform: uppercase;"> <i>Lorem ipsum</i> </h3>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris arcu sapien, dignissim id laoreet quis, sollicitudin sed dui. Mauris mauris ligula, hendrerit sed ligula vitae, viverra auctor eros. Duis rutrum dolor a felis elementum, eu facilisis justo
sollicitudin.
<br><br> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris arcu sapien, dignissim id laoreet quis, sollicitudin sed dui. Mauris mauris ligula, hendrerit sed ligula vitae, viverra auctor eros. Duis rutrum dolor a felis elementum,
eu facilisis justo sollicitudin.
<br><br><br>
Read more
</p>
</div>
<div>
</div>
<div>
</div>
</div>
<div id="crop" style=" display: inline-block; ">
<img src="http://media.caranddriver.com/images/media/51/2017-10best-lead-photo-672628-s-original.jpg" alt="" style=" " />
</div>
</section>
2. For only text to be on left and heading on center. Add this css.
/* For only text Left and heading center */
#welcome-content-inner {
text-align: left;
}
#welcome-content-inner h3 {
text-align: center;
}
.button-yellow,
.button-red {
font: 16px AdobeCaslonPro;
text-decoration: none;
padding: 6px 12px 6px 12px;
border-right: 1px solid #333333;
border-bottom: 1px solid #333333;
border-radius: 4px;
moz-border-radius: 4px;
webkit-border-radius: 4px;
font-style: italic;
}
.button-yellow {
background-color: #ccb96b;
color: #430615;
}
.button-red {
background-color: #430615;
color: #ccb96b;
margin-top: -20px;
}
#section-welcome-content {
text-align: center;
}
#welcome-content {
width: 45%;
margin: 0 0 0 0;
}
#welcome-content-inner {
background-color: #ccb96b;
color: #430615;
padding: 50px;
z-index: 10;
position: relative;
}
#welcome-content p {}
#crop {
width: 600px;
height: 500px;
overflow: hidden;
margin: 0 0 0 -50px;
}
#crop img {
width: 800px;
height: 600px;
margin: -75px 0 0 -100px;
z-index: 1;
}
/* For only text Left and heading center */
#welcome-content-inner {
text-align: left;
}
#welcome-content-inner h3 {
text-align: center;
}
<section id="section-welcome-content" class="pad">
<div id="welcome-content" style=" display: inline-block; ">
<div id="welcome-content-inner">
<p>
<h3 style="font-size: 1.5em; text-transform: uppercase;"> <i>Lorem ipsum</i> </h3>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris arcu sapien, dignissim id laoreet quis, sollicitudin sed dui. Mauris mauris ligula, hendrerit sed ligula vitae, viverra auctor eros. Duis rutrum dolor a felis elementum, eu facilisis justo
sollicitudin.
<br><br> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris arcu sapien, dignissim id laoreet quis, sollicitudin sed dui. Mauris mauris ligula, hendrerit sed ligula vitae, viverra auctor eros. Duis rutrum dolor a felis elementum,
eu facilisis justo sollicitudin.
<br><br><br>
Read more
</p>
</div>
<div>
</div>
<div>
</div>
</div>
<div id="crop" style=" display: inline-block; ">
<img src="http://media.caranddriver.com/images/media/51/2017-10best-lead-photo-672628-s-original.jpg" alt="" style=" " />
</div>
</section>
You just need to add text-align:left; in your welcome-content-inner div and you're there.
.button-yellow, .button-red {
font: 16px AdobeCaslonPro;
text-decoration: none;
padding: 6px 12px 6px 12px;
border-right: 1px solid #333333;
border-bottom: 1px solid #333333;
border-radius: 4px;
moz-border-radius: 4px;
webkit-border-radius: 4px;
font-style: italic;
}
.button-yellow {
background-color: #ccb96b;
color: #430615;
}
.button-red {
background-color: #430615;
color: #ccb96b;
margin-top: -20px;
}
#section-welcome-content {
text-align: center;
}
#welcome-content{
width: 45%;
margin: 0 0 0 0 ;
}
#welcome-content-inner {
background-color: #ccb96b;
color: #430615;
padding: 50px;
z-index: 10;
position: relative;
text-align: left;
}
#welcome-content p{
}
#crop {
width: 600px;
height: 500px;
overflow: hidden;
margin: 0 0 0 -50px ;
}
#crop img {
width: 800px;
height: 600px;
margin: -75px 0 0 -100px;
z-index: 1;
}
<section id="section-welcome-content" class="pad">
<div id="welcome-content" style=" display: inline-block; " >
<div id="welcome-content-inner" >
<p>
<h3 style="font-size: 1.5em; text-transform: uppercase;"> <i>Lorem ipsum</i> </h3>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris arcu sapien, dignissim id laoreet quis, sollicitudin sed dui. Mauris mauris ligula, hendrerit sed ligula vitae, viverra auctor eros. Duis rutrum dolor a felis elementum, eu facilisis justo sollicitudin.
<br><br>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris arcu sapien, dignissim id laoreet quis, sollicitudin sed dui. Mauris mauris ligula, hendrerit sed ligula vitae, viverra auctor eros. Duis rutrum dolor a felis elementum, eu facilisis justo sollicitudin.
<br><br><br>
Read more
</p>
</div>
<div>
</div>
<div>
</div>
</div>
<div id="crop" style=" display: inline-block; ">
<img src="http://media.caranddriver.com/images/media/51/2017-10best-lead-photo-672628-s-original.jpg" alt="" style=" "/>
</div>
</section>
Hope it helps.
Essentially I am trying to use the <Div> tag to create a bottom border to separate different content on the page but when I scroll to the bottom and insert the div there to separate them, it will ignore the other tags I have put and attached itself to the previous div separator.
How can I fix this? I tried using a HR tag but it did the same.
This is my code:
div {
margin: 0;
padding: 0;
}
#wrapper {
width: 100%;
margin: 0 auto;
}
#leftcolumn,
#rightcolumn {
border: none;
float: left;
min-height: 450px;
color: white;
}
#leftcolumn {
width: 50%;
}
.container {
margin-left: 10%;
width: 40%;
text-align: center;
}
#rightcolumn {
/* height: 100%;*/
width: 40%;
float: right;
background-color: #c9ccc9;
}
.border {
border-bottom: 40px solid #8dc43f;
}
p {
color: black;
}
.infotext {
color: #8dc43f;
margin-left: 30%;
font-family: 'ABeeZee', sans-serif;
font-size: 30px;
}
.infotexttitle {
color: #8dc43f;
margin-left: 25%;
font-family: 'ABeeZee', sans-serif;
font-size: 30px;
}
.infotexttitlepower {
color: #8dc43f;
margin-left: 36%;
font-family: 'ABeeZee', sans-serif;
font-size: 30px;
}
.infotexttitlecomm {
color: #8dc43f;
margin-left: 17%;
font-family: 'ABeeZee', sans-serif;
font-size: 30px;
}
.bluetags {
width: 264px;
padding: 0;
/* transform:rotate(180deg);*/
display: block;
/* border-collapse:collapse;*/
margin-left: 176px;
margin-top: 4px;
}
.greentags {
width: 264px;
padding: 0;
/* transform:rotate(180deg);*/
display: block;
/* border-collapse:collapse;*/
margin-left: 180px;
margin-top: -26px;
}
.orangetags {
width: 280px;
padding: 0;
/* transform:rotate(180deg);*/
display: block;
/* border-collapse:collapse;*/
margin-left: 175px;
margin-top: -15px;
}
.image {
position: relative;
width: 80%;
/* for IE 6 */
}
.titleimg {
margin-left: -60%;
margin-right: 10%;
}
imagetext {
position: absolute;
top: 200px;
left: 0;
width: 100%;
}
.bgimg {
background-size: cover;
width: 100%;
height: 60%;
border-collapse: collapse;
display: block;
margin: 0;
padding: 0;
}
#container {
height: 400px;
width: 400px;
position: relative;
}
#text {
z-index: 100;
position: absolute;
color: white;
font-size: 24px;
font-weight: bold;
left: 43%;
top: 25%;
font-family: 'ABeeZee', sans-serif;
}
#secondtext {
z-index: 100;
position: absolute;
color: white;
font-size: 24px;
font-weight: bold;
left: 37%;
top: 30%;
font-family: 'ABeeZee', sans-serif;
}
<div id="cssmenu">
<ul>
<img src="turtletag.png" class="titleimg">
<li><span>Home</span>
</li>
<li><span>Features</span>
</li>
<li><span>App</span>
</li>
<li><span>Products</span>
</li>
<li><span>Support</span>
</li>
</ul>
</div>
<img src="googlestore.png" style="position:absolute; top:210px;left:70px; width: 10%;">
<img src="appstore.png" style="position:absolute; top:320px; left:77px; width:10%;">
Order Tags
<img src="iPhone5_Mockup_Template_Free_by_Ray.png" class="bgimg">
<p id="text">Turtle Tags</p>
<p id="secondtext">Always connected to the nest</p>
<div class="border"></div>
<div id="leftcolumn">
<div class="mainbody">
<img src="bluetags.png" class="bluetags hvr-float">
</div>
<div class="mainbody">
<img src="greentags.png" class="greentags hvr-float">
</div>
<div class="mainbody">
<img src="orangetag.png" class="orangetags hvr-float">
</div>
</div>
<a name="features"></a>
<div id="rightcolumn">
<h2 class="infotext">Features</h2>
<hr class="newstyle">
<img src="battery.png" style="margin-left:40%; width:15%">
<p class="infotexttitle">Long battery life</p>
<p rows="4" columns="4" style="width:350px;margin-left:100px;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur urna enim, aliquet non sagittis sit amet, euismod luctus risus. Aliquam venenatis arcu quam, id hendrerit dolor fermentum sed. Nullam congue molestie dolor quis egestas. Suspendisse
potenti.
</p>
<img src="speaker-xxl.png" style="margin-left:45%; width:10%; margin-top:30px;">
<p class="infotexttitle">Noise Notifications</p>
<p rows="4" columns="4" style="width:350px;margin-left:100px;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur urna enim, aliquet non sagittis sit amet, euismod luctus risus. Aliquam venenatis arcu quam, id hendrerit dolor fermentum sed. Nullam congue molestie dolor quis egestas. Suspendisse potenti.
</p>
<img src="powericon.png" style="margin-left:45%; width:10%; margin-top:30px;">
<p class="infotexttitlepower">Always on</p>
<p rows="4" columns="4" style="width:350px;margin-left:100px;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur urna enim, aliquet non sagittis sit amet, euismod luctus risus. Aliquam venenatis arcu quam, id hendrerit dolor fermentum sed. Nullam congue molestie dolor quis egestas. Suspendisse potenti.
</p>
<img src="twoway.png" style="margin-left:45%; width:10%; margin-top:30px;">
<p class="infotexttitlecomm">Two way communication</p>
<p rows="4" columns="4" style="width:350px; margin-left:100px;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur urna enim, aliquet non sagittis sit amet, euismod luctus risus. Aliquam venenatis arcu quam, id hendrerit dolor fermentum sed. Nullam congue molestie dolor quis egestas. Suspendisse potenti.
</p>
</div>
I've tried changing the css and I can't find anything that would cause it, But a fresh pair of eyes may be able to find something I cannot.
The problem here comes from how you constructed your page. You have a left/right column that was built using floats. when you use float, it takes the content in the float out of the general flow of the page. Try to remove those floats and it should work as expected.
I removed your floats in the fiddle and the border started working right.
https://jsfiddle.net/ahmadabdul3/ghogvcsx/4/
here's a basic idea on how floats work: the top boxes don't overlap because there is no float, but the bottom 2 boxes you only see green because the red one is floated so the green one takes its space. to avoid this, add an explicit height to the floated div, but then you can't have dynamically expanding content. https://jsfiddle.net/ahmadabdul3/bL8qLa6j/2/
and here's a basic idea of how columns work: https://jsfiddle.net/ahmadabdul3/bL8qLa6j/5/
There's a problem in my code attached below:
The img with id listItemProfile stays always in middle no matter what padding I set, I though it might due to there's some padding in its parent, but I couldn't find any, any thoughts?
Thanks in advance!
<!DOCTYPE html>
<html>
<head>
</head>
<style type="text/css">
.accordionOm {
position: relative;
padding: 10px 0 10px 30px;
margin: 0;
font: 300 18px 'Oswald', Arial, Helvetica, sans-serif;
cursor: pointer;
}
.accordionOm:hover {
color: #000;
}
.accordionOm:before,
.accordionOm:after {
content: "";
position: absolute;
background: #333;
display: inline-block;
}
.accordionOm:before {
width: 20px;
height: 2px;
left: 0;
top: 22px;
}
.accordionOm:after {
width: 2px;
height: 20px;
left: 9px;
top: 13px;
transition: transform .5s;
transform: rotate(0);
}
.accordionOm.opened:after {
transform: rotate(90deg);
}
.accordionOm + div {
border-left: 4px solid #999;
padding: 0 15px;
margin-left: 8px;
font: 13px 'Open Sans', Arial, Helvetica, sans-serif;
color: #666;
}
* {
font-family: Arial, Verdana, sans-serif;
color: #665544;
text-align: center;}
body {
width: 100%;
margin: 0 auto;
}
#trailBar{
margin-left: 35px;
margin-right: 35px;
margin-top: 25px;
margin-bottom: 25px;
height: 180px;
background: -webkit-linear-gradient(right, #31a7de, #31a7de 35px, white 35px, white);
border: transparent;
border-radius:0.25em;
}
p.trailTextTop{
padding-top: 25px;
padding-left: 25px;
padding-right: 60px;
padding-bottom: 25px;
font-size: large;
}
p.trailTextBot{
padding-left: 25px;
padding-right: 60px;
padding-bottom: 25px;
font-size: large;
}
.left { float: left; }
.right { float: right; }
p { overflow: hidden; }
.panel-group .list-group {
margin-bottom: 0;
}
.panel-group .list-group .list-group-item {
border-radius: 0;
border-left: none;
border-right: none;
}
.panel-group .list-group .list-group-item:last-child {
border-bottom: none;
}
.panel-body{
background: #efefef;
}
#listItem{
position: relative;
height: 200px;
background: #efefef;
}
#listItemProfile{
position: absolute;
height: 80px;
width: 80px;
padding-top: 60px;
padding-bottom: 60px;
padding-left: 35px;
}
#listItemTitle{
}
#listItemSubtitle{
}
#listItemInfo{
}
#listItemArrow{
}
</style>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h4 class="accordionOm opened">
<div id="listItem">
<img id = "listItemProfile" src="images/Portrait.png">
<div id="listItemTitle">
</div>
<div id="listItemSubtitle">
</div>
<div id="listItemInfo">
</div>
<div id="listItemArrow">
</div>
</div>
</h4>
<div>
<div id="trailBar">
<p class="trailTextTop"><span class='left'>Good morning, I just start my first day trip. Happy pedal!</span></p>
<p class="trailTextBot"><span class='left'>Time 7:20</span><span class='right'>45 Miles</span></p>
</div>
<div id="trailBar">
<p class="trailTextTop"><span class='left'>Good morning, I just start my first day trip. Happy pedal!</span></p>
<p class="trailTextBot"><span class='left'>Time 7:20</span><span class='right'>45 Miles</span></p>
</div>
<div id="trailBar">
<p class="trailTextTop"><span class='left'>Good morning, I just start my first day trip. Happy pedal!</span></p>
<p class="trailTextBot"><span class='left'>Time 7:20</span><span class='right'>45 Miles</span></p>
</div>
</div>
<h4 class="accordionOm">Accordian heading</h4>
<div>
<p>Lorem ipsum dolor sit amet, adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa
quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus.</p>
</div>
<h4 class="accordionOm">Accordian heading</h4>
<div>
<p>Lorem ipsum dolor sit amet, adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa
quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus.</p>
</div>
<h4 class="accordionOm">Accordian heading</h4>
<div>
<p>Lorem ipsum dolor sit amet, adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa
quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus.</p>
</div>
</body>
<script>
$('.accordionOm').next().hide();
$(".opened").next().show();
$('.accordionOm').click(function() {
if ($(this).hasClass("opened") == true) {
$(this).next().slideUp("slow");
$(this).removeClass('opened');
} else {
$(".opened").next().slideUp("slow");
$(".opened").removeClass("opened");
$(this).addClass('opened');
$(this).next().slideDown("slow");
}
});
</script>
</html>
Hi now define this css
#listItemProfile {
position: absolute;
height: 80px;
width: 80px;
/* padding-top: 60px; */
/* padding-bottom: 60px; */
/* padding-left: 35px; */
left: 50%;
top: 50%;
margin-left: -40px; // your total width img / 2
margin-top: -40px; // your total height img /2
}
You can use this css given below :
#listItemProfile {
position: absolute;
height: 80px;
width: 80px;
left: 50%;
top: 50%;
margin-left: -40px;
margin-top: -40px;
}
try with margin-left , margin-right
Example
.class-name{
margin-left:10px;
margin-right:50px;
}
As Illustrated in the next graphic I have a problem with my responsive code: I have 3 sections called square1, 2 and 3 with a white div inside. text on top of it and an icon with an absolute position. Everything fine from 920px to higher browsing. Now, from 720 to 940 pixels I'm trying to give this 3 elements a 50% of width, to display two on top and 1 at the bottom, but centered. so far is a mess. Could someone explain me what I'm doing wrong? my actual DEMO
HTML:
<div id="section2">
<div id="centralize2">
<div id="square1">
<div id="white1">
<img src="images/hexagon1.png" class="hexagon" />
<h2 class="title1">Ipsum Dolor Consectetur1</h2>
<h3 class="description2">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla a dolor ac sapien semper maximus vel vel arcu. Praesent venenatis semper ornare. Donec blandit feugiat tellus. </h3>
</div>
</div>
<div id="square2">
<div id="white1">
<img src="images/hexagon2.png" class="hexagon" />
<h2 class="title1">Ipsum Dolor Consectetur2</h2>
<h3 class="description2">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla a dolor ac sapien semper maximus vel vel arcu. Praesent venenatis semper ornare. Donec blandit feugiat tellus. </h3>
</div>
</div>
<div id="square3">
<div id="white1">
<img src="images/hexagon3.png" class="hexagon" />
<h2 class="title1">Ipsum Dolor Consectetur3</h2>
<h3 class="description2">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla a dolor ac sapien semper maximus vel vel arcu. Praesent venenatis semper ornare. Donec blandit feugiat tellus. </h3>
</div>
</div>
</div>
</div>
Thanks!!
You can use flexbox to achieve what you want. Don't use absolute positioning if it's not necessary. If the width is bigger than 940px, the divs will display next to each other. Try it out in the full version of the code snippet.
Also cleaned up some code, as you can't have multiple divs with the same id. That's not valid markup. Use a class instead.
#section2 {
position: relative;
background-color: #112e4c;
overflow: hidden;
}
#square1, #square2, #square3 {
margin-top: 59px;
}
.white1 {
margin: 20px;
background-color: #fff;
text-align: center;
}
.hexagon {
position: absolute;
left: 50%;
}
.title1 {
font-size:18px;
margin-top: 90px;
font-family: 'Ubuntu', sans-serif;
color: #112e4c;
font-weight: 600;
}
.description2 {
font-size: 14px;
line-height: 16px;
margin-top:20px;
padding-left: 20px;
padding-right: 20px;
text-align: center;
color: #8da0b4;
}
#media all and (min-width:720px) {
#centralize2 {
display: flex;
flex-flow: row wrap;
}
#square1, #square2, #square3 {
flex-basis: calc(50%);
}
}
#media all and (min-width:940px) {
#square1, #square2, #square3 {
flex-basis: calc(100%/3);
}
}
<body>
<div id="section2">
<div id="centralize2">
<div id="square1">
<div class="white1">
<h2 class="title1">Ipsum Dolor Consectetur1</h2>
<h3 class="description2">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla a dolor ac sapien semper maximus vel vel arcu. Praesent venenatis semper ornare. Donec blandit feugiat tellus. </h3>
</div>
</div>
<div id="square2">
<div class="white1">
<h2 class="title1">Ipsum Dolor Consectetur2</h2>
<h3 class="description2">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla a dolor ac sapien semper maximus vel vel arcu. Praesent venenatis semper ornare. Donec blandit feugiat tellus. </h3>
</div>
</div>
<div id="square3">
<div class="white1">
<h2 class="title1">Ipsum Dolor Consectetur3</h2>
<h3 class="description2">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla a dolor ac sapien semper maximus vel vel arcu. Praesent venenatis semper ornare. Donec blandit feugiat tellus. </h3>
</div>
</div>
</div>
</div>
</body>
It has to do with your absolute positioning. Try removing the absolute positioning, and try floating the blocks left and add your margins as needed. Will try and get a working demo together for you asap, at work atm.
Got a chance to try and edit your demo, I believe you're looking for something like this https://jsfiddle.net/ah5zz8qq/
#section2 {
width: 100%;
background-color: #112e4c;
overflow: hidden;
}
#centralize2 {
width: 880px;
height: 310px;
margin: 40px auto;
text-align: center;
}
#square1 {
display: block;
float: left;
width: 33.3%;
position: relative;
}
#square2 {
display: block;
float: left;
width: 33.3%;
position: relative;
}
#square3 {
display: block;
float: left;
width: 33.3%;
position: relative;
}
#white1 {
width: 280px;
height: 250px;
background-color: #fff;
text-align: center;
position: relative;
}
.hexagon {
position: absolute;
left: 50%;
top: 0;
margin-left: -52px;
margin-top: -59px;
}
.title1 {
display: block;
font-size:18px;
font-family: 'Ubuntu', sans-serif;
color: #112e4c;
font-weight: 600;
}
.description2 {
font-size: 14px;
line-height: 16px;
margin-top:20px;
padding-left: 20px;
padding-right: 20px;
text-align: center;
color: #8da0b4;
}
#media all and (max-width:940px) {
#centralize2 {
width: 90%;
}
#section2 {
height: 720px;
}
#square1 {
display: block;
width: 50%;
float: left;
}
#square2 {
display: block;
width: 50%;
float: left;
margin-bottom: 10px;
}
#square3 {
display: block;
clear: both;
width: 50%;
float: none;
margin: 0 auto;
}
#white1 {
width:300px;
}
}
#media all and (max-width:720px) {
#section2 {
height: 1070px;
}
#buttons {
margin-top:25px;
}
#square1 {
width: 100%;
}
#square2 {
width: 100%;
margin-top:340px;
}
#square3 {
width: 100%;
margin-top:340px;
}
#white1 {
width: 100%;
position: absolute;
}
}
}