Link to project
I've have finally managed to get the header layout I want but one thing I can't get done and that is the alignment of the text (h2 and h3) in the left sidebar. I have tried to do it with a fixed proportie but it get side-effects and I think it has something to do with the rotated text.
The main title should be in left bottom, on one line and the date should be on the right of the main title also on one line. Those combined must align at center of the side-main text aligned to the left.
Edit: Link to layout
* {
padding: 0;
margin: 0;
font-family: 'Roboto', sans-serif;
}
.wrapper-header {
display: flex;
background: linear-gradient(to right bottom, #F33C12, #F28BB8);
}
.top-nav {
position: fixed;
width: 100%;
height: 60px;
background: rgba(255, 255, 255, .2);
}
.side-main {
display: flex;
flex-direction: column;
height: calc(100vh - 60px);
margin-top: 60px;
width: 70px;
border-right: 1px rgba(255, 255, 255, .2) solid;
}
.agenda-text {
width: 100%;
color: #FFF;
transform: rotate(-90deg);
text-transform: uppercase;
}
.header-main {
display: flex;
height: calc(100vh - 60px);
margin-top: 60px;
}
<html>
<head>
<title>Rataplan Improvisatietheater</title>
<link href="https://fonts.googleapis.com/css?family=Roboto:400,400i,500,700" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="top-nav">
nav
</div>
<div class="wrapper-header">
<div class="side-main">
<h2 class="agenda-text">Main Title Event</h2>
<h3 class="agenda-text">Event date 1 (month) 2018</h3>
</div>
<div class="header-main">
main
</div>
</div>
<div class="wrapper-content">
<h1>Lorem Ipsum</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Suscipit velit, natus dolores, exercitationem debitis praesentium. Ipsam, nesciunt, vero placeat repellendus hic ex, numquam eos iste earum cum dolores omnis maiores.</p>
</div>
</body>
</html>
Many thanks in advance!
Hope you can help me out.
Regards,
Jason
This doesn't look super polished as a whole yet, but I believe it does solve your issue with the rotation of the side-main.
Html:
<!DOCTYPE html>
<html>
<head>
<title>Rataplan Improvisatietheater</title>
<link href="https://fonts.googleapis.com/css?family=Roboto:400,400i,500,700" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="top-nav">
nav
</div>
<div class="wrapper-header">
<div class="side-main-wrapper">
<div class="side-main">
<h2 class="agenda-text">Main Title Event</h2>
<h3 class="agenda-text">Event date 1 (month) 2018</h3>
</div>
</div>
<div class="header-main">
main
</div>
</div>
<div class="wrapper-content">
<h1>Lorem Ipsum</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Suscipit velit, natus dolores, exercitationem debitis praesentium. Ipsam, nesciunt, vero placeat repellendus hic ex, numquam eos iste earum cum dolores omnis maiores.</p>
</div>
</body>
</html>
Css:
*{
padding: 0;
margin: 0;
font-family: 'Roboto', sans-serif;
}
.wrapper-header{
display: flex;
background: linear-gradient(to right bottom, #F33C12, #F28BB8);
}
.top-nav{
position: fixed;
width: 100%;
height: 60px;
background: rgba(255,255,255,.2);
}
.side-main-wrapper {
transform: rotate(-90deg);
margin-top: 60px;
}
.side-main{
display: flex;
flex-direction: column;
height: 70px;
width: calc(100vh - 60px);
border-bottom: 1px rgba(255,255,255,.2) solid;
}
.agenda-text{
color: #FFF;
text-transform: uppercase;
}
.header-main{
height: calc(100vh - 60px);
margin-top: 60px;
}
Rather than rotating the entries of the flex column, I wrapped the side-main in a side-main-wrapper and rotated that. Then I just treated the side-main as a regular flex column, and it started behaving.
I added flex: 1; and some margin-left to .agenda-text and then opened up the .side-main width a bit. Hope this is something like what you are looking for, but just guessing since you didn't specify
Edit: Looks wack in preview and fullscreen... but works in the actual edit jsfiddle screen... maybe this is not a good answer
Edit Took out flex: 1 and margin-left. I've made it look how you described, but with an issue. I think a big step forward is adding a container around the .agenda-texts and then rotate that instead of the text. The problem with my approach is that the flex positioning is based on the width of the sidebar, before everything gets turned sideways. So with a left bar width like 300px it works but with a smaller width like you are looking for probably not. Can't imagine making this fully responsive without doing the whole thing over
* {
padding: 0;
margin: 0;
font-family: 'Roboto', sans-serif;
}
.wrapper-header {
display: flex;
background: linear-gradient(to right bottom, #F33C12, #F28BB8);
}
.top-nav {
position: fixed;
width: 100%;
height: 60px;
background: rgba(255, 255, 255, .2);
}
.side-main {
height: calc(100vh - 60px);
margin-top: 60px;
width: 300px;
border-right: 1px rgba(255, 255, 255, .2) solid;
}
.side-main-title {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100%;
transform: rotate(-90deg);
}
.agenda-text {
color: #FFF;
text-transform: uppercase;
}
.header-main {
display: flex;
height: calc(100vh - 60px);
margin-top: 60px;
}
<!DOCTYPE html>
<html>
<head>
<title>Rataplan Improvisatietheater</title>
<link href="https://fonts.googleapis.com/css?family=Roboto:400,400i,500,700" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div class="top-nav">
nav
</div>
<div class="wrapper-header">
<div class="side-main">
<div class="side-main-title">
<h2 class="agenda-text">Main Title Event</h2>
<h3 class="agenda-text">Event date 1 (month) 2018</h3>
</div>
</div>
<div class="header-main">
main
</div>
</div>
<div class="wrapper-content">
<h1>Lorem Ipsum</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Suscipit velit, natus dolores, exercitationem debitis praesentium. Ipsam, nesciunt, vero placeat repellendus hic ex, numquam eos iste earum cum dolores omnis maiores.</p>
</div>
</body>
</html>
Related
I'm making 2 cards in CSS and I want the 2nd one to lay below the 1st one. In order to locate the first card in the middle I created a "card-outer" div, but when I click "inspect element" I see that the height of the outer is more than 900px, and therefore, the 2nd card is +900px lower than the 1st card.
Do you guys have any idea of how can I fix this issue?
It looks like this, and I want only a 50px separation between both:
.card-outer {
display: flex;
justify-content: center;
min-height: 100vh;
}
.card {
width: 500px;
height: 250px;
display: flex;
overflow: hidden;
background: rgb(16, 33, 72);
box-shadow: 0 5px 10px #031e23;
border-radius: 30px;
color: white;
font-family: 'Dosis';
margin-top: 50px;
}
.card .img-card {
background: url(parque.png);
width: 40%;
height: 100%;
background-size: cover;
background-position: 60% 0%;
}
.card .content {
width: 60%;
height: 100%;
display: grid;
grid-template-rows: 50px 150px 50px;
padding: 10px 15px;
}
<div class="card-outer">
<div class="card">
<div class="img-card"></div>
<div class="content">
<div class="titulo">
<h3>Parque Metropolitano</h3>
</div>
<div class="text">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Commodi consectetur, accusamus repellat architecto veritatis quis vel harum molestiae tempore ea illo ut sapiente magnam voluptate.
</p>
</div>
<div class="btn-container">
<button>Sitio web</button>
</div>
</div>
</div>
</div>
Assuming the .card-outer is the wrapper for the layout, use the gap property on your .card-outer to make your 50px separate and use justify and align to get the cards where you want them within the wrapper.
If .card-outer isn't a wrapper, create one using the same technique.
.card-outer {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 100vh;
gap: 50px; /*this guy right here */
}
.card {
width: 500px;
height: 250px;
display: flex;
overflow: hidden;
background: rgb(16, 33, 72);
box-shadow: 0 5px 10px #031e23;
border-radius: 30px;
color: white;
font-family: 'Dosis';
margin-top: 50px;
}
.card .img-card {
background: url(parque.png);
width: 40%;
height: 100%;
background-size: cover;
background-position: 60% 0%;
}
.card .content {
width: 60%;
height: 100%;
display: grid;
grid-template-rows: 50px 150px 50px;
padding: 10px 15px;
}
<div class="card-outer">
<div class="card">
<div class="img-card"></div>
<div class="content">
<div class="titulo">
<h3>Parque Metropolitano</h3>
</div>
<div class="text">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Commodi consectetur, accusamus repellat architecto veritatis quis vel harum molestiae tempore ea illo ut sapiente magnam voluptate.
</p>
</div>
<div class="btn-container">
<button>Sitio web</button>
</div>
</div>
</div>
<div class="card">
<div class="img-card"></div>
<div class="content">
<div class="titulo">
<h3>Parque Metropolitano</h3>
</div>
<div class="text">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Commodi consectetur, accusamus repellat architecto veritatis quis vel harum molestiae tempore ea illo ut sapiente magnam voluptate.
</p>
</div>
<div class="btn-container">
<button>Sitio web</button>
</div>
</div>
</div>
</div>
I have a transparent navbar which always keeps overlaying the main content.
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Navbar</title>
<link rel="stylesheet" href="styles.css">
<!-- <script src="index.js"></script> -->
</head>
<body>
<header id="header_main">
<div id="d1">
<h1 id="h1_title_responsive">YASH</h1>
</div>
<ul id="ul_nav">
<li class="li_nav" id="li1"><img src="logo.png" id="logo_img"></li>
<li class="li_nav" id="li2">Home</li>
<li class="li_nav" id="li3">About</li>
<li class="li_nav" id="li4">Contact</li>
<h1 id="h1_title">YASH</h1>
<li id="search_li"><input name="search" id="search_box" placeholder="Search this website" type="text"></li>
</ul>
</header>
<div id="d2">
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quos ipsam et quam eum placeat consequatur iure at rerum? Necessitatibus numquam facilis, fugiat non eum ipsum. Aperiam maxime provident harum quia!
Lorem ipsum dolor sit amet consectetur adipisicing elit. Culpa excepturi a nihil laudantium corporis fugit quisquam enim natus facilis dolor. Vitae quibusdam blanditiis atque, eligendi architecto hic repellat amet accusantium!
Lorem ipsum dolor sit amet consectetur adipisicing elit. Ea fugit enim natus? Aspernatur libero alias unde veniam cumque impedit cum corrupti facere consectetur molestiae laudantium, asperiores esse quis, autem saepe
</p>
</div>
</body>
</html>
CSS:
*{
margin: 0;
padding: 0;
}
#header_main{
background-color: rgba(0, 0, 0, 0.6);
position: fixed;
width: 100%;
}
body{
background: red;
}
.li_nav{
list-style: none;
margin: 0.9vh 1vw;
font-size: large;
z-index: 1;
font-weight: bolder;
}
a{
color: white;
text-decoration: none;
padding: 2px;
border-radius: 3px;
}
.a_text:hover{
color: black;
background: white;
}
#li1{
color: white;
}
#logo_img{
height: 40px;
width: auto;
}
#ul_nav{
display: flex;
align-items: center;
justify-content: left;
}
#h1_title{
color: white;
display: flex;
justify-content: center;
position: absolute;
width: 100%;
}
#d1{
display: none;
}
#h1_title_responsive{
display: flex;
color: white;
justify-content: center;
position:relative;
width: 100vw;
}
#search_box{
border-radius: 7px;
height: 2em;
font-size: 80%;
font-weight: bolder;
width: 170%;
}
#search_li{
list-style: none;
position: absolute;
left: 75%;
width: 12.5%;
}
#d2{
height: 1000vh;
}
#media (max-width: 700px) {
#h1{
visibility: hidden;
}
#d1{
display: flex;
}
}
This is a screenshot of the issue:
[enter image description here][1]
https://i.stack.imgur.com/WgWoL.png
and in my css the #d2 is 1000vh because I want the navbar to work perfectly even when scrolling
The navbar position: fixed means that the navbar element is removed from the flow of the document.
You can find the full explanation of what position: fixed does here: https://developer.mozilla.org/en-US/docs/Web/CSS/position.
To prevent the navbar from covering the main content, you have to add either some padding or margin above the content.
#d2{
padding-top: // height of the navbar + some extra
}
The navbar has position fixed. Read more here: https://developer.mozilla.org/en-US/docs/Web/CSS/position
Fix this by adding a height to your navbar.
Example:
#header_main{
background-color: rgba(0, 0, 0, 0.6);
position: fixed;
width: 100%;
height:50px; /*set to your own*/
}
I am developing a chat system UI, I faced problems with aligning items left and right
I want to display my message on the right and someone else's messages on the left.
Current code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#container {
margin: 5% auto;
width: 40%;
padding: 10px;
margin-bottom: 40px;
border: 1px solid red;
}
.chat {
border: 1px ridge #34495e;
}
.msg-box {
background: green;
width: 50%;
padding: 10px;
}
</style>
</head>
<body>
<div id="container">
<div class="chat">
<p class="border msg-box msg-my">Lorem ipsum, dolor sit amet consectetur, adipisicing elit. Vitae, accusan</p>
<p class="border msg-box">Lorem ipsum, dolor sit amet consectetur, adipisicing elit. Vitae, accusan</p>
</div>
</div>
</body>
</html>
NOTE need just alignment left and right, not styling elements.
Example:
Perhaps this will get you started:
https://codepen.io/riza-khan/pen/dyXjwoW
<div class="chat-container">
<div class="me">Hi! How are you?</div>
<div class="you">Hello! Great, and yourself?</div>
<div class="me">Pretty good! How's the weather on your end?</div>
<div class="you">Getting chilly, winter is almost here :)</div>
<div class="me">Lorem ipsum dolor sit amet consectetur, adipisicing elit. Modi eos nemo totam illum consequuntur hic exercitationem laudantium ab doloribus debitis.</div>
<div class="you">Lorem ipsum dolor sit amet consectetur, adipisicing elit. Modi eos nemo totam illum consequuntur hic exercitationem laudantium ab doloribus debitis.</div>
</div>
.chat-container {
display: flex;
flex-direction: column;
.me,
.you {
margin-top: 1.5rem;
padding: 0.5rem;
border-radius: 0.5rem;
}
.me {
margin-left: auto;
border: solid 1px blue;
max-width: 55%;
}
.you {
margin-right: auto;
border: solid 1px red;
max-width: 55%;
}
}
.chat{
display:flex;
flex-direction:column;
background: #f0f0f0;
width: 400px;
}
.chat_bubble_container{
display:flex;
width: 400px;
}
.chat_bubble_container.incoming{
justify-content: flex-start;
}
.chat_bubble_container.outgoing{
justify-content: flex-end;
}
.chat_bubble_container .chat_bubble{
display:flex;
padding: 4px;
border-radius: 5px;
margin: 5px;
}
.chat_bubble_container.incoming .chat_bubble{
background: #d1d1d1;
}
.chat_bubble_container.outgoing .chat_bubble{
background: #429bd7;
color: white;
}
<div class="chat">
<div class="chat_bubble_container incoming">
<div class="chat_bubble">Hi</div>
</div>
<div class="chat_bubble_container outgoing">
<div class="chat_bubble">Hi</div>
</div>
<div class="chat_bubble_container incoming">
<div class="chat_bubble">Lorem ipsum</div>
</div>
<div class="chat_bubble_container outgoing">
<div class="chat_bubble">Lorem ipsum</div>
</div>
</div>
This was solution :/
.msg-my {
margin-left: auto;
}
I have tried my best to solve the issue but it's not working. I want to make a gradient border on my website for a slideshow (similar to the one on this video). I used (:before) pseudo selector here is my HTML code:
* {
color: white;
margin: 0px 0px;
padding: 0px 0px;
box-sizing: border-box;
}
body {
background-color: #060c21;
}
/* NavBar Starts */
#mainnav {
display: flex;
justify-content: center;
padding: 15px;
background-color: black;
width: 98%;
position: static;
}
.items>a {
font-family: "Roboto Slab", serif;
text-decoration: none;
}
.items {
margin: 0 5vw 0 5vw;
padding: 1vw;
width: fit-content;
font-size: 1.3rem;
}
.items>a:hover {
color: rgb(0, 255, 242);
}
/* NavBar Ends */
/* Content Starts */
.slide-box {
position: relative;
border: 2px solid red;
height: 75vh;
width: 95%;
margin: 2% auto;
}
.slide-box:before {
content: '';
position: absolute;
top: -2px;
left: -2px;
right: -2px;
bottom: -2px;
background: white;
z-index: -1;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Practice</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto+Slab:wght#531&display=swap" rel="stylesheet" />
<!-- font-family: 'Roboto Slab', serif; -->
<link rel="stylesheet" href="Vaishnavi.css" />
</head>
<body>
<nav>
<div id="mainnav">
<div class="items">
Home
</div>
<div class="items">
About US
</div>
<div class="items">
Creations
</div>
<div class="items">
Help
</div>
</div>
</nav>
<div class="slide-box">
<h1>This is glowing box</h1>
<p>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Quo voluptatibus et quasi illum inventore rem excepturi quam tenetur eius est, minima aliquam repellendus deleniti modi laudantium similique iste ipsum? Ad!
</p>
</div>
</body>
</html>
Please tell me the mistake I am making and why my z-index is not working correctly. In my view, I have written the code correctly.
Is this something that you are looking for?
You can see that I recreated the example based on this video that you have provided.
* {
color: white;
margin: 0px 0px;
padding: 0px 0px;
box-sizing: border-box;
}
body {
background-color: #060c21;
}
/* NavBar Starts */
#mainnav {
display: flex;
justify-content: center;
padding: 15px;
background-color: black;
width: 98%;
position: static;
}
.items>a {
font-family: "Roboto Slab", serif;
text-decoration: none;
}
.items {
margin: 0 5vw 0 5vw;
padding: 1vw;
width: fit-content;
font-size: 1.3rem;
}
.items>a:hover {
color: rgb(0, 255, 242);
}
/* NavBar Ends */
/* Content Starts */
.slide-box {
position: relative;
margin: 2% auto;
height: 75vh;
width: 95%;
background: linear-gradient(0deg, #000, #262626);
}
.slide-box:before {
content: '';
position: absolute;
top: -2px;
left: -2px;
background: linear-gradient(45deg, #fb0094, #0000ff, #00ff00, #ffff00, #ff0000, #fb0094, #0000ff, #00ff00, #ffff00, #ff0000);
background-size: 400%;
width: calc(100% + 4px);
height: calc(100% + 4px);
z-index: -1;
animation: animate 20s linear infinite;
}
#keyframes animate {
0% {
background-position: 0 0;
}
50% {
background-position: 400% 0;
}
100% {
background-position: 0 0;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Practice</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto+Slab:wght#531&display=swap" rel="stylesheet" />
<!-- font-family: 'Roboto Slab', serif; -->
<link rel="stylesheet" href="Vaishnavi.css" />
</head>
<body>
<nav>
<div id="mainnav">
<div class="items">
Home
</div>
<div class="items">
About US
</div>
<div class="items">
Creations
</div>
<div class="items">
Help
</div>
</div>
</nav>
<div class="slide-box">
<h1>This is glowing box</h1>
<p>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Quo voluptatibus et quasi illum inventore rem excepturi quam tenetur eius est, minima aliquam repellendus deleniti modi laudantium similique iste ipsum? Ad!
</p>
</div>
</body>
</html>
What you were missing in your code to see the text was the line below:
.slide-box {
background: linear-gradient(0deg, #000, #262626);
}
The z-index worked just fine but because your background color was white and also the text color was white, you could not see the text.
Here is the code how you can achieve gradient border(code is copied from css-tricks). For more please visit here
body {
height: 100vh;
margin: 0;
display: grid;
place-items: center;
background: #222;
}
.module-border-wrap {
max-width: 250px;
padding: 1rem;
position: relative;
background: linear-gradient(to right, red, purple);
padding: 3px;
}
.module {
background: #222;
color: white;
padding: 2rem;
}
<div class="module-border-wrap">
<div class="module">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Vero pariatur corporis quaerat voluptatum eos tempora temporibus nisi voluptates sed, exercitationem sequi dolore culpa incidunt accusamus, quasi unde reprehenderit ea molestias.
</div>
</div>
Can someone please help me?!
I'm trying to code a PSD file to HTML and CSS, but I'm struggling with one of the sections. Here's an image of what I want to do:
Click Here
The problem is I don't know how to put the image in the timeline line. I tried to add the image in the ::after psuedo, but I don't think this is the right way of doing that.
This is my HTML Code :
<section class="about">
<div class="wrapper">
<h3>About Us</h3>
<p>Lorem ipsum dolor sit amet consectetur.</p>
<div class="container left">
<div class="content">
<h5>JULY 2010<br> Our Humble Beginnings</h5>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Rerum officia labore fugit nihil nulla laboriosam praesentium harum ut, odio ea facere, recusandae reprehenderit repellat.</p>
</div>
</div>
<div class="container right">
<div class="content">
<h5>January 2011<br> Facing Startups Battles</h5>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Rerum officia labore fugit nihil nulla laboriosam praesentium harum ut, odio ea facere, recusandae reprehenderit repellat.</p>
</div>
</div>
</div>
</section>
This is my CSS code:
.about .wrapper{
padding: 80px 10%;
text-align: center;
position: relative;
}
.about .wrapper::after{
content: '';
position: absolute;
top: 200px;
bottom: 0;
width: 6px;
background: red;
}
.about h5{
line-height: 1.5;
font-size: 1em;
padding-bottom: .5em;
}
.about .container{
position: relative;
width: 50%;
top: 60px;
margin: 0 0 60px 0;
}
.about .container::after{
content: 'How Can I Add an Image Here in this circle?';
position: absolute;
width: 200px;
height: 200px;
border-radius: 50%;
top: 20px;
right: -104px;
background-color: blue; /* Just because there is no image */
background-image: url(assets/img/about-1.png);
background-repeat: no-repeat;
background-size: cover;
z-index: 2;
}
.left{
text-align: right;
}
.right{
text-align: right;
}
.content{
padding: 30px 0px 80px 0px;
}
.left .content{
padding-right: 140px;
}
.right .content{
padding-left: 140px
}
.right{
text-align: left;
left: 50%;
}
.right:after {
left: -104px;
}
I think this is called a timeline, there is a lot of tutorials talking about how to do something like this, but I don't know how to make the images in the timeline line. Can you please help me do this?
Thanks
To build this, you could use css grid layout (guide: https://css-tricks.com/snippets/css/complete-guide-grid/)
Treat each of the content+image as a row in the layout. And each row as a container for a grid.
You can visually break every row down to 3 columns. One column for left-side content, the second one for the image and the third one for right-side content.
Example css grid for a layout like this:
.grid-container {
display: grid;
grid-template-columns: 1fr 10em 1fr;
grid-template-rows: 1fr;
grid-template-areas: "content-left image content-right";
text-align: center;
}
.content-left { grid-area: content-left; background: lightblue; }
.image { grid-area: image; background: lightgreen; }
.content-right { grid-area: content-right; background: lightblue; }
<div class="grid-container">
<div class="content-left">Left content</div>
<div class="image">Image</div>
<div class="content-right">Right content</div>
</div>
(grid generated with: https://grid.layoutit.com/)
To alternate between content on the left and on the right, you can use css even/odd selectors (How can I style even and odd elements?) to set which grid area is used for the element.
Example:
I've built an example of a timeline layout for this answer which you can find at https://codepen.io/hendrysadrak/pen/VwLEraz
Try this:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="main.css" />
<title></title>
</head>
<body>
<section class="about">
<div class="wrapper">
<div>
<h3>About Us</h3>
<p>Lorem ipsum dolor sit amet consectetur.</p>
</div>
<div id="container">
<div class="row">
<div id="col1" class="col right">
<h5>JULY 2010<br> Our Humble Beginnings</h5>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Rerum officia labore fugit nihil nulla laboriosam praesentium harum ut, odio ea facere, recusandae reprehenderit repellat.</p>
</div>
<div id="col2" class="col"><img class="img" src="assets/img/about-1.png"/></div>
</div>
<div class="row2" >
<div id="col3" class="col"><img class="img" src="assets/img/about-1.png"/></div>
<div id="col4" class="col left">
<h5>JULY 2010<br> Our Humble Beginnings</h5>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Rerum officia labore fugit nihil nulla laboriosam praesentium harum ut, odio ea facere, recusandae reprehenderit repellat.</p>
</div>
</div>
</div>
</div>
</section>
</body>
</html>
in main.css file:
.about .wrapper{
padding: 80px 10%;
text-align: center;
}
.about h5{
line-height: 1.5;
font-size: 1em;
padding-bottom: .5em;
}
.row {
width: 59%;
margin-right: 41%;
display: flex;
}
.row2 {
width: 59%;
display: flex;
margin-left: 41%;
}
.col {
flex:1;
}
.col.left {
text-align: left;
}
.col.right {
text-align: right;
}
#col2 {
flex-basis: 30%;
}
#col1 {
flex-basis: 70%;
}
#col3 {
flex-basis: 30%;
}
#col4 {
flex-basis: 70%;
}
.img {
margin: 10% 5%;
width: 90%;
border-radius: 50%;
}
#container {
background-image: linear-gradient(lightgrey,lightgrey);
background-size: 2px 100%;
background-repeat: no-repeat;
background-position: center center;
}
put this in assets/img/about-1.png