I am trying to wrap div text with flex but its not working, the title div seems to be overlapping the other post divs, I have tried using line height and applying flex wrap, still no fix. I've also tried centering with css grid but that didn't seem to get either,If anyone can help me with this thank you.
*,
*::before,
*::after {
font-family: Mukta, sans-serif;
}
body {
margin: 0;
padding: 0;
}
#header {
display: flex;
flex-direction: column;
gap: 25px;
justify-content: center;
align-items: center;
width: 100%;
height: 20%;
}
#quote {
display: flex;
font-weight: 300;
font-size: 20px;
}
#name {
font-size: 55px;
}
#navlist {
display: flex;
padding-inline-start: 0px;
gap: 40px;
}
#navlistelm {
padding: 15px 38px;
font-size: 20px;
font-weight: 200;
list-style: none;
}
#navbar {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
width: 100%;
height: 20%;
}
#navimgcontainer {
display: flex;
flex-direction: row;
width: 100%;
height: 70%;
}
img {
height: 500px;
width: 1950px;
}
#aboutcontainer {
display: flex;
width: 80%;
height: 100%;
gap: 40px;
}
#about {
display: flex;
justify-content: center;
align-items: center;
height: 70%;
width: 100%;
}
#aboutText {
display: flex;
font-size: 20px;
font-weight: 400;
flex-direction: column;
gap: 40px;
width: 100%;
}
#abouttitle {
font-weight: 700;
font-size: 40px;
}
#aboutImage {
display: flex;
justify-content: center;
align-items: center;
height: 90%;
width: 50%;
}
#ebookcontainer {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 80%;
}
#econtainer {
display: flex;
flex-direction: row;
justify-content: flex-end;
width: 75%;
height: 80%;
background-color: #dd927c;
border-radius: 5px;
}
#ebookimage {
display: flex;
width: 45%;
height: 100%;
justify-content: flex-end;
align-items: center;
justify-content: center;
}
#ebook {
height: 585px;
width: 550px;
}
#etext {
display: flex;
flex-direction: column;
align-items: center;
width: 60%;
height: 100%;
}
#ebookstuff {
display: flex;
justify-content: flex-end;
align-items: center;
text-align: center;
font-family: Dancing Script, 'sans serif';
width: 80%;
height: 50%;
color: white;
font-size: 80px
}
#egraph {
display: flex;
color: white;
padding-inline-start: 60px;
width: 100%;
height: 20%;
font-size: 30px;
}
#ebookdirect {
display: flex;
align-items: center;
justify-content: center;
height: 50%;
width: 100%;
}
#ebutton {
border: none;
color: white;
font-size: 30px;
background-color: rgba(201, 115, 116, 255);
border-radius: 5px;
height: 60px;
width: 400px;
}
#ebutton:hover {
cursor: pointer;
}
#subscribelist {
padding: 0px;
list-style: none;
}
#subscribelistelm {
display: flex;
padding: 10px;
}
#footer {
display: flex;
flex-direction: column;
width: 100%;
height: 80%;
}
#text {
display: flex;
gap: 10px;
flex-direction: column;
width: 100%;
height: 20%;
}
#postcontainer {
display: flex;
width: 100%;
height: 100%;
justify-content: center;
align-items: center;
}
#post1 {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 40px;
height: 100%;
width: 30%;
}
#postimg {
height: 300px;
width: 300px;
}
#postbutton1 {
border: none;
color: white;
font-size: 20px;
background-color: #de8e7a;
width: 30%;
height: 5%;
}
#post1title {
font-size: 30px;
font-weight: bold;
}
#post1preview {}
<link href="https://fonts.googleapis.com/css2?family=Dancing+Script&family=Mukta:wght#200;300;400;500;600&display=swap" rel="stylesheet">
<section id="header">
<div id="name">CAVETTA JOHNSON</div>
<div id="quote">Living life with intention. Live don't just exist.</div>
</section>
<nav id="navbar">
<ul id="navlist">
<li id="navlistelm">Home</li>
<li id="navlistelm">Travel Blog</li>
<li id="navlistelm">ebook</li>
<li id="navlistelm">Merchandise</li>
<li id="navlistelm">1 On 1 Session</li>
<li id="navlistelm">About Us</li>
</ul>
</nav>
<div id="navimgcontainer">
<img src="./images/CAVETTA JOHNSON.png" alt="">
</div>
<section id="about">
<div id="aboutcontainer">
<div id="aboutText">
<div id="abouttitle">I finally decided to start living!</div>
Hey hey hey! My name is Cavetta, and welcome to Life With Vetta. I am a mom to 2 amazing boys. Kal-El 16 And Jor-El 11. I have been divorced and a single mom for a few years now. Juggling raising the men of tomorrow, working, having a life outside of
my boys (nonexistent). We LOVE to travel. I originally moved from Jamaica to California for college. The travel bug had bitten me and the need to see the world and what it has to offer has always been with me. I went on a few cruises before kids,
traveled to different states and cities, exploring and wandering. When I found myself with 2 kids, alone I knew one of my first goals was to show them the world and let them see things outside of their comfort zone. We took our first cruise when
they were itsy bitsy and had a blast. Since then, we traveled the states, city hopping and seeing their home country. We then trotted over to London and Paris when they were older and that struck a chord and lit a fire that was not going to be tamed
by anything but travel and adventure. I had been thinking and considering being a digital nomad.
</div>
<div id="aboutImage">
<img src="./images/IMG_3238.jpg" alt="">
</div>
</div>
</section>
<section id="ebookcontainer">
<div id="econtainer">
<div id="etext">
<div id="ebookstuff">So you want to travel the world
</div>
<div id="egraph">I do not have millions in the bank but I am making it happen without stress or worry.</div>
<div id="ebookdirect">
<button id="ebutton">Download!</button>
</div>
</div>
<div id="ebookimage">
<img src="./images/Digital Download! (1).png" alt="" id="ebook">
</div>
</div>
</section>
<section id="postcontainer">
<div id="post1">
<div id="post1img">
<img id="postimg" src="./images/Digital Download! (1).png" alt="">
</div>
<div id="post1title">YOO</div>
<div id="post1preview">sssssssssss</div>
<button id="postbutton1">Read More!</button>
</div>
<div id="post1">
<div id="post1img">
<img id="postimg" src="./images/Digital Download! (1).png" alt="">
</div>
<div id="post1title">YOO</div>
<div id="post1preview">sssssss</div>
<button id="postbutton1">Read More!</button>
</div>
<div id="post1">
<div id="post1img">
<img id="postimg" src="./images/Digital Download! (1).png" alt="">
</div>
<div id="post1title">YOOdddddddddddddddddddddddddddddddddddddddddddddddd</div>
<div id="post1preview">ssssssddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddds</div>
<button id="postbutton1">Read More!</button>
</div>
</section>
<section id="footer">
<div id="Text">
<div id="title">Subscribe To Follow Our Adventures</div>
<div id="signup">Get the latest updates on where we are and what fabulous experiences we are having!</div>
</div>
<div id="Subscribe">
<form action="api" id="subscribeform">
<ul id="subscribelist">
<li id="subscribelistelm">
<input type="firstname" id="firstname" name="user_firstname" />
</li>
<li id="subscribelistelm">
<input type="lastname" id="lastname" name="user_lastname" />
</li>
<li id="subscribelistelm">
<input type="email">
</li>
<li id="subscribebutton">
<button>Yo</button>
</li>
</form>
</div>
</section>
One solution would be to assign width and word-wrap.
For example for the #post1title id:
#post1title {
font-size: 30px;
font-weight: bold;
width:100%;
word-wrap: break-word;
}
Related
Just finished a mini project and everything seemed to be going accordingly until I completed the footer this page. For each section, the divs do not stretch to the end, which wasn't an issue before. I'm assuming it's something to do with the pixels on the page?
Notice the gap on the left/right of the screen:
enter image description here
enter image description here
HTML:
<body>
<div class="header">
<div class="header-left">
<div class="logo">Header Logo</div>
</div>
<div class="header-right">
<div class="links-top">
<li>header link one</li>
<li>header link two</li>
<li>header link three</li>
</div>
</div>
</div>
<div class="hero">
<div class="hero-left-head">
<h1>This website is awesome</h1>
<p>This website has some subtext that goes here under the main title. It’s a smaller font and the color is lower contrast.</p>
<button class="hero-button">Sign Up</button>
</div>
<div class="sade">
<img src="https://s3.us-east-1.amazonaws.com/vnda-cockpit/www-streetopia-me/2020/09/11/5f5bfd8c2bb85sade01.jpg" alt="sade" height="200" width="350">
</div>
</div>
<div class="middle">
<div class="title"><h1>Some Information?</h1></div>
<div class="bmw-pics">
<div class="bmw-text">
<img src="https://aprperformance.com/wp-content/uploads/2015/01/BMW_M4_Lip_Installed_LR_7.jpg" alt="puke-green">
<p>Puke Green</p>
</div>
<div class="bmw-text">
<img src="https://cdn.bmwblog.com/wp-content/uploads/2015/03/Yas-Marina-Blue-BMW-F80-M3-Gets-Some-Essential-Updates-7.jpg" alt="yas">
<p>Yas Marina</p>
</div>
<div class="bmw-text">
<img src="https://f80.bimmerpost.com/forums/attachment.php?attachmentid=2671354&stc=1&d=1628858312" alt="Frost White">
<p>Frost White</p>
</div>
<div class="bmw-text">
<img src="https://1c2a8a2161d644d95009-22d26b38e78c173d82b3a9a01c774ffa.ssl.cf1.rackcdn.com/image/projectcars/f80m3/f80_m3_carbon_mirror_covers_7_w705.jpg" alt="Imola Red">
<p>Imola Red</p>
</div>
</div>
</div>
<div class="above-footer">
<div class="above-footer-p1">
<p>If you do what you've always done, then you'll get what you've always had, you dumb buffons!</p>
</div>
<div class="above-footer-p2">
<p>- A Wise Prophet</p>
</div>
</div>
<div class="last-space">
<div class="blue-box">
<div class="action"><strong>Call to action! It's time!</strong></div>
<div class="product-bit">Sign up for our product by clicking the button to your right :)</div>
<button class="last-button">Sign Up!</button>
</div>
</div>
<div class="footer">
<p>Copyright © The Odin Project 2021</p>
</div>
</body>
CSS:
.header {
background-color: #1F2937;
display: flex;
justify-content: space-around;
color: #f9faf8;
font-size: 24px;
padding: 10px;
}
.links-top {
list-style-type: none;
display: flex;
margin: 0;
padding: 0;
gap: 16px;
font-size: 20px;
}
a {
text-decoration: none;
color: #f9faf8;
}
p {
font-size: 15px;
}
.hero {
display: flex;
flex-direction: row;
background-color: #1F2937;
gap: 50px;
align-items: center;
justify-content: center;
padding-bottom: 30px;
}
.hero-left-head {
font-size: 24px;
color: #f9faf8;
}
.sade {
display: flex;
align-items: center;
justify-content: center;
border-radius: 10px;
}
.hero-button {
background-color: #3882F6;
color:#f9faf8;
border-radius: 25px;
padding: 0;
height: 30px;
width: 100px;
}
.middle {
display: flex;
flex-direction: column;
color:#1F2937;
}
.bmw-pics {
display: flex;
margin-left: auto;
margin-right: auto;
gap: 20px;
}
.bmw-text img {
height: 260px;
border-radius: 10px;
width: 250px;
}
.bmw-text p {
text-align: center;
}
.title {
text-align: center;
}
.above-footer {
background-color: #e5e7eb;
justify-content: center;
display: flex;
flex-direction: column;
}
.above-footer-p1 p,
.above-footer-p2 p {
font-size: 36px;
}
.above-footer-p2 {
display: flex;
justify-content: flex-end;
margin-right: 50px;
}
.above-footer-p1 p {
font-style: italic;
margin-top: 100px;
color: #1F2937;
display: flex;
align-items: center;
justify-content: center;
}
.last-space {
color: #f9faf8;
display: flex;
justify-content: center;
align-items: center;
}
.blue-box {
display: flex;
background-color: #3882F6;
width: 800px;
margin: 50px;
flex-direction: column;
padding: 50px;
border-radius: 15px;
}
.last-button {
align-self: flex-end;
padding:5px 25px 5px 25px;
color:#F9FAF8;
background-color: #3882F6;
border-radius: 10px;
border-color: #F9FAF8;
justify-content: center;
}
.footer {
background-color: #1F2937;
color: #F9FAF8;
display: flex;
justify-content: center;
align-items: center;
}
Please forgive the extensive css sheet, I'm still learning :) Any help is greatly appreciated!
There's margin on the body. By default the body element has 8px of margin on all sides. You can resolve this by adding this CSS to your project:
body {
margin: 0;
}
Some call this a CSS reset. You can learn more here. Hope this helps!
It's because the body html element (along with many other elements) has margin automatically applied. You can just clear it by adding this to your CSS:
body {
margin: 0px
}
You might want to try using something like Normalize.css for your projects. It really removes a lot of these "why is this happening" issues related to CSS. Also, you should read up on your browser's Devtools (on Chrome, for example, you can click Ctrl+Shift+i and it will open. You can then inspect specific elements and it will tell you why a certain element has a certain style.
For example, you can see that by hovering over the first paragraph of your post that it has a margin-bottom of 1.1em because it is selected by .s-prose p.
Hope that helps!
This question already has answers here:
How can I horizontally center an element?
(133 answers)
Closed 5 months ago.
header {
display: flex;
justify-content: space-between;
}
nav {
display: flex;
text-align: right;
align-items: center;
}
body {
font-size: 20px;
margin: 0px;
justify-content: center;
}
.logo {
text-align: left;
align-items: center;
}
.menu {
margin-left: 10px;
}
a {
text-decoration: none;
color: #000000;
}
.welcome {
background-color: #76a5d5;
width: 100%;
height: 300px;
display: flex;
align-items: center;
justify-content: center;
}
.welcome .p1 {
font-size: 40px;
}
main {
width: 1200px;
background-color: #76a5d5;
margin: 10px;
display: flex;
justify-content: center;
}
main>.item {
flex: none;
width: 580px;
height: 50px;
margin: 10px;
background-color: #000000;
}
<header>
<div class="logo">My Website</div>
<nav>
<div class="menu">
<a class="navitem_text" href="##">item1</a>
</div>
<div class="menu">
<a class="navitem_text" href="##">item2</a>
</div>
<div class="menu">
<a class="navitem_text" href="##">item3</a>
</div>
<div class="menu">
<a class="navitem_text" href="##">item4</a>
</div>
</nav>
</header>
<div class="welcome">
<div class="p1">Welcome to MyHome</div>
</div>
<main>
<div class="item">
</div>
</main>
hi I just started learning coding.I wanted to create a rwd page.Now I'm facing a problem is that I want to move my main area to the center of the page but I couldn't do it. I've tried to add display:flex to body. But everything would move. Should I add a div in the main? Can't figure it out. What should i do now? Here's the code.Thanks
You want to center the main element right?
main{
width: 1200px;
background-color: #76a5d5;
/*See here 10px will be used for top and bottom and for left and right
it will automatically divide equally both sides using auto.
*/
margin: 10px auto;
display: flex;
justify-content: center;
}
Try replacing this ruleset in your css.
Using auto for the left and right margin gives the desired result.
header {
display: flex;
justify-content: space-between;
}
nav {
display: flex;
text-align: right;
align-items: center;
}
body {
font-size: 20px;
margin: 0px;
justify-content: center;
}
.logo {
text-align: left;
align-items: center;
}
.menu {
margin-left: 10px;
}
a {
text-decoration: none;
color: #000000;
}
.welcome {
background-color: #76a5d5;
width: 100%;
height: 300px;
display: flex;
align-items: center;
justify-content: center;
}
.welcome .p1 {
font-size: 40px;
}
main {
width: 1200px;
background-color: #76a5d5;
margin: 10px auto;
display: flex;
justify-content: center;
}
main>.item {
flex: none;
width: 580px;
height: 50px;
margin: 10px;
background-color: #000000;
}
<header>
<div class="logo">My Website</div>
<nav>
<div class="menu">
<a class="navitem_text" href="##">item1</a>
</div>
<div class="menu">
<a class="navitem_text" href="##">item2</a>
</div>
<div class="menu">
<a class="navitem_text" href="##">item3</a>
</div>
<div class="menu">
<a class="navitem_text" href="##">item4</a>
</div>
</nav>
</header>
<div class="welcome">
<div class="p1">Welcome to MyHome</div>
</div>
<main>
<div class="item">
</div>
</main>
Answer
You can do this with CSS align-self property.
First, we need give the <body> display flex and set the direction to column (vertical).
body {
font-size: 20px;
margin: 0px;
display: flex;
flex-direction: column; /* this change the direction to vertical */
}
then change the main area to center
main {
width: 1200px;
background-color: #76a5d5;
margin: 10px;
align-self: center; /* this move the element to center */
}
Demo
header{
display: flex;
justify-content: space-between;
}
nav{
display: flex;
text-align: right;
align-items: center;
}
body{
font-size: 20px;
margin: 0px;
display: flex;
flex-direction: column;
}
.logo{
text-align: left;
align-items: center;
}
.menu{
margin-left: 10px;
}
a{
text-decoration: none;
color:#000000;
}
.welcome{
background-color: #76a5d5;
width: 100%;
height: 300px;
display: flex;
align-items: center;
justify-content: center;
}
.welcome .p1{
font-size: 40px;
}
main{
width: 1200px;
background-color: #76a5d5;
margin: 10px;
align-self: center;
}
main>.item{
flex: none;
width: 580px;
height: 50px;
margin: 10px;
background-color: #000000;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=divice-width, initial-scale=1">
<link rel="stylesheet" href="RWDstyle.css"/>
<title>RWD test</title>
</head>
<body>
<header>
<div class="logo">My Website</div>
<nav>
<div class="menu">
<a class="navitem_text" href="##">item1</a>
</div>
<div class="menu">
<a class="navitem_text" href="##">item2</a>
</div>
<div class="menu">
<a class="navitem_text" href="##">item3</a>
</div>
<div class="menu">
<a class="navitem_text" href="##">item4</a>
</div>
</nav>
</header>
<div class="welcome">
<div class="p1">Welcome to MyHome</div>
</div>
<main>
<div class="item">
</div>
</main>
</body>
</html>
I wan't to add a p like this.
I can add it, but when I use margin-top to put it down, it affects the elements above like this.
I don't know how to solve this.
Thank you.
HTML.
<main>
<section class="home">
<div class="presentation">
<p class="hello">HELLO THERE</p>
<p>I'm Lautaro Rojas</p>
<p>Web developer</p>
<p class="scroll">SCROLL DOWN</p>
</div>
<div class="presentation-buttons">
<button>LATEST PROJECTS</button>
<button>MORE ABOUT ME</button>
</div>
</section>
</main>
CSS:
main {
width: 100%;
height: 100%;
.home {
width: 100%;
height: 100%;
background-image: url("../img/bg.jpg");
background-size: cover;
display: flex;
align-items: center;
.presentation {
width: 70%;
height: 100%;
display: flex;
flex-flow: column;
justify-content: center;
align-items: center;
gap: 5px;
p {
width: 50%;
margin: 0;
text-align: left;
color: $WHITE;
font-family: Merriweather-Regular;
font-size: 70px;
letter-spacing: 2px;
}
p[class="hello"] {
font-size: 30px;
color: $PINK;
}
p[class="scroll"] {
margin-top:180px;
font-size: 10px;
}
}
}
}
position: absolute; is your friend...
<main>
<section class="home">
<div class="presentation">
<p class="hello">HELLO THERE</p>
<p>I'm Lautaro Rojas</p>
<p>Web developer</p>
<p class="scroll">SCROLL DOWN</p>
</div>
<div class="presentation-buttons">
<button>LATEST PROJECTS</button>
<button>MORE ABOUT ME</button>
</div>
</section>
</main>
main {
width: 100%;
height: 100%;
.home {
width: 100%;
height: 100%;
background-image: url("../img/bg.jpg");
background-size: cover;
display: flex;
align-items: center;
.presentation {
width: 70%;
height: 100%;
display: flex;
flex-flow: column;
justify-content: center;
align-items: center;
gap: 5px;
position: relative;
p {
width: 50%;
margin: 0;
text-align: left;
color: $WHITE;
font-family: Merriweather-Regular;
font-size: 70px;
letter-spacing: 2px;
}
p[class="hello"] {
font-size: 30px;
color: $PINK;
}
p[class="scroll"] {
margin-top:180px;
font-size: 10px;
position: absolute;
}
}
}
}
I am working on the Free Code Camp project for which you need to make a product landing page.
I have everything that I want already except for two things.
The navigation bar goes behind the hero header image
When the user scrolls down, I want the navigation bar to be hidden – it currently does not do this.
Here is my code:
#import "https://fonts.googleapis.com/css?family=Lato:400,700";
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: #eee;
font-family: 'Lato', sans-serif;
}
#page-wrapper {
position: relative;
}
li {
list-style: none;
}
a {
color: #000;
text-decoration: none;
}
/** global classes styling **/
.container {
max-width: 1000px;
width: 100%;
margin: 0 auto;
}
.btn {
padding: 0 20px;
height: 40px;
font-size: 1em;
font-weight: 900;
text-transform: uppercase;
border: 3px black solid;
border-radius: 2px;
background: transparent;
cursor: pointer;
}
.grid {
display: flex;
}
header {
position: fixed;
top: 0;
min-height: 75px;
padding: 0px 20px;
display: flex;
justify-content: space-around;
align-items: center;
background-color: #eee;
}
#media (max-width: 600px) {
header {
flex-wrap: wrap;
}
}
.logo {
width: 60vw;
}
#media (max-width: 650px) {
.logo {
margin-top: 15px;
width: 100%;
position: relative;
}
}
.logo>img {
width: 100%;
height: 100%;
max-width: 300px;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
margin-left: 20px;
}
#media (max-width: 650px) {
.logo>img {
margin: 0 auto;
}
}
nav {
font-weight: 400;
background-color: white;
}
#media (max-width: 650px) {
nav {
margin-top: 10px;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
padding: 0 50px;
transition: top 0.1s;
/* Transition effect when sliding down (and up) */
}
nav li {
padding-bottom: 5px;
}
}
nav>ul {
width: 35vw;
display: flex;
flex-direction: row;
justify-content: space-around;
}
#media (max-width: 650px) {
nav>ul {
flex-direction: column;
}
}
#hero {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
height: 300px;
margin-top: 50px;
}
#hero>h2 {
margin-bottom: 20px;
word-wrap: break-word;
}
#hero input[type="email"] {
max-width: 275px;
width: 100%;
padding: 5px;
}
#hero input[type="submit"] {
max-width: 150px;
width: 100%;
height: 30px;
margin: 15px 0;
border: 0;
background-color: #f1c40f;
}
#hero input[type="submit"]:hover {
background-color: orange;
transition: background-color 1s;
}
#media (max-width: 650px) {
#hero {
margin-top: 120px;
}
}
#features {
margin-top: 30px;
}
#features .icon {
display: flex;
align-items: center;
justify-content: center;
height: 125px;
width: 20vw;
color: darkorange;
}
#media (max-width: 550px) {
#features .icon {
display: none;
}
}
#features .desc {
display: flex;
flex-direction: column;
justify-content: center;
height: 125px;
width: 80vw;
padding: 5px;
}
#media (max-width: 550px) {
#features .desc {
width: 100%;
text-align: center;
padding: 0;
height: 150px;
}
}
#media (max-width: 650px) {
#features {
margin-top: 0;
}
}
#aboutOurApp {
margin-top: 50px;
display: flex;
justify-content: center;
}
#aboutOurApp>iframe {
max-width: 560px;
width: 100%;
}
#pricing {
margin-top: 50px;
display: flex;
flex-direction: row;
justify-content: center;
}
#aboutOurCompany {
margin-top: 1px;
display: flex;
flex-direction: row;
justify-content: center;
}
.product {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
width: calc(100% / 3);
margin: 10px;
border: 1px solid #000;
border-radius: 3px;
}
.product>.level {
background-color: #ddd;
color: black;
padding: 15px 0;
width: 100%;
text-transform: uppercase;
font-weight: 700;
}
.product>h2 {
margin-top: 15px;
}
.product>ol {
margin: 15px 0;
}
.product>ol>li {
padding: 5px 0;
}
.product>button {
border: 0;
margin: 15px 0;
background-color: #f1c40f;
font-weight: 400;
}
.product>button:hover {
background-color: orange;
transition: background-color 1s;
}
#media (max-width: 800px) {
#pricing {
flex-direction: column;
}
.product {
max-width: 300px;
width: 100%;
margin: 0 auto;
margin-bottom: 10px;
}
}
footer {
margin-top: 30px;
background-color: white;
padding: 20px;
}
footer>ul {
display: flex;
justify-content: flex-end;
}
footer>ul>li {
padding: 0 10px;
}
footer>span {
margin-top: 5px;
display: flex;
justify-content: flex-end;
font-size: 0.9em;
color: #444;
}
body {
background-color: white;
}
.hero-image {
/* Use "linear-gradient" to add a darken background effect to the image (photographer.jpg). This will make the text easier to read */
background-image: url("https://collectivecloud.org/wp-content/uploads/2019/12/iphone-410324_1280-1024x682.jpg");
/* Set a specific height */
height: 900px;
width: 1920px;
max-width: 100%;
/* Position and center the image to scale nicely on all screens */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
}
.hero-text {
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
font-size: 50px;
}
.hero-text button {
border: none;
outline: 0;
display: inline-block;
padding: 10px 25px;
color: black;
background-color: #ddd;
text-align: center;
cursor: pointer;
}
.hero-text button:hover {
background-color: #555;
color: white;
}
<div id="page-wrapper">
<header id="header">
<div class="logo">
<img id="header-img" src="https://collectivecloud.org/wp-content/uploads/2019/07/image-1-350x200.png" alt="Collective Cloud logo (This is really my company by the way ust in case)" />
</div>
<nav id="nav-bar">
<ul>
<li><a class="nav-link" href="#features">Features</a></li>
<li><a class="nav-link" href="#aboutOurApp">About Our App</a></li>
<li><a class="nav-link" href="#pricing">Pricing</a></li>
</ul>
</nav>
</header>
<div class="container">
<section id="hero" class="hero-image">
<div class="full-width">
<div class="hero-text">
<h1>Auto Build Websites</h1>
<p>Best app out there
</p>
<p style="padding: -100px;">
</div>
</div>
</div>
</section>
<p style="padding: 30px;">
<div class="container" id="features">
<section id="features">
<div class="grid" id="features">
<img src="https://cdn2.iconfinder.com/data/icons/weather-2-4/100/Weather_Set-07-512.png" height="200px" width="200" />
<div class="desc">
<h2 style="color: #0ac0ed;">SEO Optimization</h2>
<p>
Increases the quality and quantity of website traffic by increasing the visibility of a website or a web page to users of a web search engine
</p>
</div>
</div>
<div class="grid">
<img src="https://cdn2.iconfinder.com/data/icons/weather-2-4/100/Weather_Set-07-512.png" height="200px" width="200" />
<div class="desc">
<h2 style="color: #0ac0ed;">Responsive Design</h2>
<p>
Responsive web design is an approach to web design that makes web pages render well on a variety of devices and window or screen sizes.
</p>
</div>
</div>
<div class="grid">
<img src="https://cdn2.iconfinder.com/data/icons/weather-2-4/100/Weather_Set-07-512.png" height="200px" width="200" />
<div class="desc">
<h2 style="color: #0ac0ed;">24/7 Support</h2>
<p>
We provide 24/7 full support to our customers who are always looking to improve their business.
</p>
</div>
</div>
<p style="padding: 30px;">
</section>
<section id="aboutOurCompany">
<img src="https://collectivecloud.org/wp-content/uploads/2019/07/image-1-350x200.png" width="350" height="200" alt="image-1" title="image-1" padding:50px>
<p>We at Collective Cloud, LLC offer a range of services that will improve your business and help your business have a better internet presence. We offer a pro website with features tailored to your business that will give you a competing edge in
your industry.</p>
</section>
<p style="padding: 30px;">
<section id="pricing">
<div class="product" id="tenor">
<div class="level" style="background-color: #3aa8fc;">Free App</div>
<h2>FREE</h2>
<ol>
<li>Contains Ads</li>
<li>Restricted Functionality</li>
<li>No Social Media</li>
</ol>
<button class="btn">Select</button>
</div>
<div class="product" id="bass">
<div class="level" style="background-color: #3aa8fc;">Paid App</div>
<h2>$100</h2>
<ol>
<li>No Ads</li>
<li>Full functionality</li>
<li>Can Upgrade</li>
</ol>
<button class="btn">Select</button>
</div>
<div class="product" id="valve">
<div class="level" style="background-color: #3aa8fc;">Pro App</div>
<h2>$200</h2>
<ol>
<li>No Ads</li>
<li>Premium Functionalities</li>
<li>Code-Level Support</li>
</ol>
<button class="btn">Select</button>
</div>
</section>
<section id="aboutOurApp">
<div id="video" style="text-align: center;">
<p style="padding: 30px;">
<h1>Checkout How it Works</h1>
<p style="padding: 90px;">
<iframe width="560" height="315" src="https://www.youtube.com/embed/MWV45qb9nCQ" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</section>
<section id="hero">
<h1>Best Website Development App in the World</h1>
<h2>Don't miss out on any updates!</h2>
<form id="form" action="https://www.freecodecamp.com/email-submit">
<input name="email" id="email" type="email" placeholder="Subscribe Now" required />
<input id="submit" type="submit" value="Get Started" class="btn" />
</form>
</section>
<footer style="align-content: center;">
<ul>
<li>Privacy</li>
<li>Terms</li>
<li>Contact</li>
<li>About Us</li>
</ul>
<span>Copyright 2020, Collective Cloud, LLC</span>
</footer>
</div>
</div>
in your CSS add
position: relative;
left: -14px;
or just use
overflow: hidden; //it won't show at all
overflow: auto; //scrollbar will only show when content is more
I am try to write markup and css for table based design in flexbox module !
Here is the Design
Here is the Markup
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.header-area {
margin: 50px auto;
max-width: 800px;
}
.flextable-header {
width: 100%;
background: #f7f7f7;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
height: 45px;
}
.flextable-header span {
width: 20%;
text-align: center;
}
.flextable-header .amount {
flex: auto;
text-align: right;
padding-right: 30px;
}
.flextable-content {
height: 100px;
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.flextable-content div {
width: 20%;
text-align: center;
}
.text-left {
display: flex;
flex-direction: column;
justify-content: center;
font-size: 15px;
height: 100%;
}
#dates {
text-align: left;
display: inline-block;
}
.flextable-content .money {
flex: auto;
text-align: right;
padding-right: 30px;
}
.flextable-content div img {
width: 120px;
height: 80px;
border-radius: 5px;
object-fit: cover;
object-position: center;
}
<div class="header-area">
<div class="flextable-header">
<span>Photos</span>
<span>Date</span>
<span class="amount">Amount</span>
</div>
<div class="flextable-content">
<div><img src="https://i.imgur.com/VzV3NwJ.jpg" alt=""></div>
<div class="text-left">
<div>Business</div><br/>
<div id="dates">25 December 2019</div>
</div>
<div class="money">3500 <small>Taka</small></div>
</div>
</div>
I'm stack at date alignment and bottom border as per design which I put on top !
You can simplify your code like below and use a simple gradient for the line:
* {
box-sizing: border-box;
}
.header-area {
margin: 50px auto;
max-width: 800px;
}
.flextable-header,
.flextable-content{
background: #f7f7f7;
display: flex;
align-items: center;
height: 45px;
}
.flextable-header > span:first-child {
min-width:130px;
text-align:center;
}
.flextable-header .amount,
.flextable-content .money{
margin-left:auto;
padding-right: 30px;
}
.flextable-content {
height: 100px;
background:linear-gradient(grey,grey) bottom right/calc(100% - 130px) 1px no-repeat;
padding-bottom:10px;
margin:10px 0;
}
.flextable-content:last-child {
background:none;
}
.flextable-content > img {
max-width:120px;
border-radius: 5px;
}
.text-left {
padding-left:10px;
font-size: 15px;
}
<div class="header-area">
<div class="flextable-header">
<span>Photos</span>
<span>Date</span>
<span class="amount">Amount</span>
</div>
<div class="flextable-content">
<img src="https://i.imgur.com/VzV3NwJ.jpg" alt="">
<div class="text-left">
<div>Business</div>
<div class="dates">25 December 2019</div>
</div>
<div class="money">3500 <small>Taka</small></div>
</div>
<div class="flextable-content">
<img src="https://i.imgur.com/VzV3NwJ.jpg" alt="">
<div class="text-left">
<div>Business</div>
<div class="dates">25 December 2019</div>
</div>
<div class="money">3500 <small>Taka</small></div>
</div>
<div class="flextable-content">
<img src="https://i.imgur.com/VzV3NwJ.jpg" alt="">
<div class="text-left">
<div>Business</div>
<div class="dates">25 December 2019</div>
</div>
<div class="money">3500 <small>Taka</small></div>
</div>
</div>
Add width: 100% to your dates (use it as class, not id, id should be unique)
Add a spacer div at the bottom.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.header-area {
margin: 50px auto;
max-width: 800px;
}
.flextable-header {
width: 100%;
background: #f7f7f7;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
height: 45px;
}
.flextable-header span {
width: 20%;
text-align: center;
}
.flextable-header .amount {
flex: auto;
text-align: right;
padding-right: 30px;
}
.flextable-content {
height: 100px;
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.flextable-content div {
width: 20%;
text-align: center;
}
.text-left {
display: flex;
flex-direction: column;
justify-content: center;
font-size: 15px;
height: 100%;
}
div.dates {
text-align: left;
display: inline-block;
width: 100%;
}
.flextable-content .money {
flex: auto;
text-align: right;
padding-right: 30px;
}
.flextable-content div img {
width: 120px;
height: 80px;
border-radius: 5px;
object-fit: cover;
object-position: center;
}
.spacer{
height: 1px;
background-color: #e5e5e5;
width: 78%;
float: right;
margin-right: 2%;
}
<div class="header-area">
<div class="flextable-header">
<span>Photos</span>
<span>Date</span>
<span class="amount">Amount</span>
</div>
<div class="flextable-content">
<div><img src="https://i.imgur.com/VzV3NwJ.jpg" alt=""></div>
<div class="text-left">
<div>Business</div><br/>
<div class="dates">25 December 2019</div>
</div>
<div class="money">3500 <small>Taka</small></div>
</div>
<div class="spacer"></div>
</div>
And to give some rest for other users, you can also change your HTML structure and use a border as a separator
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.header-area {
margin: 50px auto;
max-width: 800px;
}
.flextable-header {
width: 100%;
background: #f7f7f7;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
height: 45px;
}
.flextable-header span {
width: 20%;
text-align: center;
}
.flextable-header .amount {
flex: auto;
text-align: right;
padding-right: 30px;
}
.flextable-content {
height: 100px;
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.img-container {
flex-basis: 20%;
flex-shrink: 0;
flex-grow: 0;
text-align: center;
}
.border-container{
flex-basis: 78%;
flex-shrink: 0;
flex-grow: 0;
display: flex;
align-items: center;
border-bottom: 1px solid #e5e5e5;
margin-right: 2%;
padding-bottom: 15px;
height: 100%;
}
.text-left {
display: flex;
flex-direction: column;
justify-content: center;
font-size: 15px;
height: 100%;
}
div.dates {
text-align: left;
display: inline-block;
width: 100%;
}
.flextable-content .money {
flex: auto;
text-align: right;
padding-right: 30px;
}
.flextable-content div img {
width: 120px;
height: 80px;
border-radius: 5px;
object-fit: cover;
object-position: center;
}
<div class="header-area">
<div class="flextable-header">
<span>Photos</span>
<span>Date</span>
<span class="amount">Amount</span>
</div>
<div class="flextable-content">
<div class="img-container"><img src="https://i.imgur.com/VzV3NwJ.jpg" alt=""></div>
<div class="border-container">
<div class="text-left">
<div>Business</div><br/>
<div class="dates">25 December 2019</div>
</div>
<div class="money">3500 <small>Taka</small></div>
</div>
</div>
</div>