On THIS page I have a layout with rows of text-photo pairs. I need the photo to have a fixed width and the text to have fluid width. The text has to be vertically centered. I have used flexbox to achieve these goals.
As can be seen below, in the list item with the id of box2, in order to place the photo to the left, I had to insert it before the text block in the DOM.
The problem: on small, mobile resolutions, when the display goes to block instead of flex, the photos of the first and second row are one after the other, when instead, there should be a block of text between them.
How can I fix that?
h3 {
max-width: 1000px;
margin: 0 auto;
padding: 65px 0;
font-size: 36px;
line-height: 1.2;
font-weight: 300;
font-family: "Open Sans", sans-serif;
}
ul.boxes {
list-style-type: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
}
ul.boxes li {
color: #3e3e3e;
display: flex;
flex-direction: row;
align-items: center;
}
ul.boxes #box1 {
background: #dcdcdc;
}
ul.boxes #box3 {
background: #6b6b6b;
color: #fff;
}
ul.boxes li .photo {
width: 402px;
max-width: 100%;
}
ul.boxes li .content {
padding: 0 65px;
width: 100%;
}
ul.boxes li h4 {
font-family: 'Oswald', sans-serif;
font-size: 16px;
margin-top: 0;
text-transform: uppercase;
}
ul.boxes li .content ul {
padding: 0;
}
ul.boxes li .content ul li {
padding-left: 20px;
background: transparent url('img/redbullet.png') no-repeat 5px 8px;
}
#media screen and (max-width: 480px) {
ul.boxes,
ul.boxes li {
display: block;
margin-bottom: 10px;
}
}
<h3 class="text-center thin">Obiectivul nostru este să fim în fiecare zi mai buni, iar munca noastră se bazează pe 3 piloni principali:
Calitate, Creativitate, Rezultate.</h3>
<ul class="boxes">
<li id="box1">
<div class="content">
<h4>Lorem ipsum dolor</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Soluta, reiciendis molestias inventore blanditiis ratione amet, dolore id doloribus minus iure esse, accusantium qui ex, nesciunt? Officiis, animi saepe libero quae!</p>
</div>
<div class="photo flex-left">
<div class="photo flex-right">
<img src="http://placehold.it/402x335">
</div>
</div>
</li>
<li id="box2">
<div class="photo flex-right">
<img src="http://placehold.it/402x335">
</div>
<div class="content">
<h4>Lorem ipsum dolor</h4>
Descoperim continuu soluții noi pentru a ne îndeplini sarcinile și pentru a trece peste provocările zilnice, ca să fim în fiecare zi mai buni.
</div>
</li>
<li id="box3">
<div class="content">
<h4>Lorem ipsum dolor</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Soluta, reiciendis molestias inventore blanditiis ratione amet, dolore id doloribus minus iure esse, accusantium qui ex, nesciunt? Officiis, animi saepe libero quae!</p>
</div>
<div class="photo flex-left">
<div class="photo flex-right">
<img src="http://placehold.it/402x335">
</div>
</div>
</li>
</ul>
Instead of display: block below (and including) 480px, you can wrap your flexbox and set order for the flex children like this:
ul.boxes,
ul.boxes li {
flex-wrap: wrap;
margin-bottom: 10px;
}
ul.boxes li .photo {
order: 2;
}
ul.boxes li .content {
order: 1;
}
I guess now you can take it forward from here - see demo below:
h3 {
max-width: 1000px;
margin: 0 auto;
padding: 65px 0;
font-size: 36px;
line-height: 1.2;
font-weight: 300;
font-family: "Open Sans", sans-serif;
}
ul.boxes {
list-style-type: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
}
ul.boxes li {
color: #3e3e3e;
display: flex;
flex-direction: row;
align-items: center;
}
ul.boxes #box1 {
background: #dcdcdc;
}
ul.boxes #box3 {
background: #6b6b6b;
color: #fff;
}
ul.boxes li .photo {
width: 402px;
max-width: 100%;
}
ul.boxes li .content {
padding: 0 65px;
width: 100%;
}
ul.boxes li h4 {
font-family: 'Oswald', sans-serif;
font-size: 16px;
margin-top: 0;
text-transform: uppercase;
}
ul.boxes li .content ul {
padding: 0;
}
ul.boxes li .content ul li {
padding-left: 20px;
background: transparent url('img/redbullet.png') no-repeat 5px 8px;
}
#media screen and (max-width: 480px) {
ul.boxes,
ul.boxes li {
flex-wrap: wrap;
margin-bottom: 10px;
}
ul.boxes li .photo {
order: 2;
}
ul.boxes li .content {
order: 1;
}
}
<h3 class="text-center thin">Obiectivul nostru este să fim în fiecare zi mai buni, iar munca noastră se bazează pe 3 piloni principali:
Calitate, Creativitate, Rezultate.</h3>
<ul class="boxes">
<li id="box1">
<div class="content">
<h4>Lorem ipsum dolor</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Soluta, reiciendis molestias inventore blanditiis ratione amet, dolore id doloribus minus iure esse, accusantium qui ex, nesciunt? Officiis, animi saepe libero quae!</p>
</div>
<div class="photo flex-left">
<div class="photo flex-right">
<img src="http://placehold.it/402x335">
</div>
</div>
</li>
<li id="box2">
<div class="photo flex-right">
<img src="http://placehold.it/402x335">
</div>
<div class="content">
<h4>Lorem ipsum dolor</h4>
Descoperim continuu soluții noi pentru a ne îndeplini sarcinile și pentru a trece peste provocările zilnice, ca să fim în fiecare zi mai buni.
</div>
</li>
<li id="box3">
<div class="content">
<h4>Lorem ipsum dolor</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Soluta, reiciendis molestias inventore blanditiis ratione amet, dolore id doloribus minus iure esse, accusantium qui ex, nesciunt? Officiis, animi saepe libero quae!</p>
</div>
<div class="photo flex-left">
<div class="photo flex-right">
<img src="http://placehold.it/402x335">
</div>
</div>
</li>
</ul>
Related
I'll explain what I'm looking for. At the moment, I created the entire layout with a CSS grid, I just missed the sidenavbar (example on the first link), but I don't know how to make a list fit in the grid, once I transform: rotate my element it goes away from the screen.
This is the model:
This is where I stand at the moment.
#import url('https://fonts.googleapis.com/css2?family=Noto+Sans:wght#100&display=swap');
* {
padding: 0;
margin: 0;
box-sizing: border-box;
font-size: medium;
font-family: noto;
}
:root {
/* colors */
--colNoirPhoto: #181818;
--col1: #2F4858;
--col2: #165B6F;
--col3: #00707E;
--col4: #008483;
--col5: #00987D;
--col6: #04AA6D;
--alt1: #0BE0BA;
--alt2: #00BFC9;
--alt3: #ffffff;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: 'Noto Sans', sans-serif;
}
/*side nav bar*/
.sidebar {
display: flex;
position: fixed;
width: 10%;
height: 100%;
color: var(--alt3);
}
/* top content--------------------------------------------------------------------------------*/
.topcontainer {
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr;
background-color: var(--colNoirPhoto);
margin-top: 7%;
width: 100%;
height: 20vh;
padding-left: 2vh;
}
.titretopcontainer {
color: var(--alt3);
display: flex;
flex-direction: column;
justify-content: center;
}
.tiretopcontainer h1 {
font-size: 18px;
}
.topcontainer img {
display: flex;
flex-direction: row;
align-items: center;
width: 88%;
grid-row-start: 1;
grid-column-start: 2;
}
/* fin detop content--------------------------------------------------------------------------------*/
/* biographie content--------------------------------------------------------------------------------*/
.containerAllContent {
display: grid;
grid-template-columns: 10% 90%;
background-image: url(/background\ page\ content.png);
}
.separateurdechapitre1 {
display: flex;
padding-left: 1vh;
padding-right: 1vh;
padding-top: 1vh;
background-color: var(--col1);
height: 5vh;
color: var(--alt3);
grid-column-start: 2;
}
.separateurdechapitre2 {
display: flex;
padding-left: 1vh;
padding-right: 1vh;
padding-top: 1vh;
background-color: var(--col2);
height: 5vh;
color: var(--alt3);
grid-column-start: 2;
}
.separateurdechapitre3 {
display: flex;
padding-left: 1vh;
padding-right: 1vh;
padding-top: 1vh;
background-color: var(--col3);
height: 5vh;
color: var(--alt3);
grid-column-start: 2;
}
.separateurdechapitre4 {
display: flex;
padding-left: 1vh;
padding-right: 1vh;
padding-top: 1vh;
background-color: var(--col4);
height: 5vh;
color: var(--alt3);
grid-column-start: 2;
}
.content {
padding-left: 2vh;
padding-right: 2vh;
padding-top: 2vh;
padding-bottom: 2vh;
grid-column-start: 2;
}
/* fin de biographie content--------------------------------------------------------------------------------*/
p {
color: black;
}
footer {
background-color: var(--col1);
}
<main>
<div class="topcontainer">
<div class="titretopcontainer">
<h1>John Conway
</h1>
<h2> Créateur du jeu de la vie
</h2>
</div>
<img src="/Photo de John Conway.png" alt="Photo de John Conway">
</div>
<div class="containerAllContent">
<div class="sidebar">
<a href="">Biographie
</a>
<a href="">Réalisations
</a>
<a href="">Distinctions
</a>
<a href="">Voir aussi
</a>
</div>
<div class="separateurdechapitre1">
<h6>En quelques lignes
</h6>
</div>
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Architecto laudantium, temporibus nemo possimus inventore
soluta amet exercitationem cumque nobis quasi?
</p>
</div>
<div class="separateurdechapitre2">
<h6>En quelques lignes
</h6>
</div>
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Architecto laudantium, temporibus nemo possimus inventore
soluta amet exercitationem cumque nobis quasi?
</p>
</div>
<div class="separateurdechapitre3">
<h6>En quelques lignes
</h6>
</div>
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Architecto laudantium, temporibus nemo possimus inventore
soluta amet exercitationem cumque nobis quasi?
</p>
</div>
<div class="separateurdechapitre4">
<h6>En quelques lignes
</h6>
</div>
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Architecto laudantium, temporibus nemo possimus inventore
soluta amet exercitationem cumque nobis quasi?
</p>
</div>
</div>
</main>
<footer>
<p>-
</p>
</footer>
Reading your question, I did not fully understand:
If you want your sidebar menu to be aligned vertically instead of horizontally as before.
Or whether you want the menu text to be laid out vertically.
Solution for 1.:
This can be done by setting the CSS property's flex-direction value to column for the element <div class="sidebar">.
CSS
.sidebar {
display: flex;
flex-direction: column;
position: fixed;
width: 10%;
height: 100%;
color: var(--alt3);
}
Solution for 2.:
This can be done by setting the CSS property's writing-mode value to vertical-lr for the element <div class="sidebar">.
CSS
.sidebar {
display: flex;
writing-mode: vertical-lr;
position: fixed;
width: 10%;
height: 100%;
color: var(--alt3);
}
I want these these 3 sections to be side by side
I want these three sections of the class box to be in line side by side. I don't know what is wrong with my code. I've cross checked it many time with the code from the instructor.
Thanks for your help.
ul {
margin: 0;
padding: 0;
}
/* Global */
.container {
width: 80%;
margin: auto;
overflow: hidden;
}
/* BOXES */
#boxes {
margin-top: 20px;
}
#boxes .box {
float: left;
width: 25%;
padding: 10px;
text-align: center;
}
#boxes .box img {
width: 90px;
}
<section id="boxes">
<div class="container">
<div class="box">
<img src="./images/html5.png" alt="html5">
<h3>HTML 5 Markup</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste corrupti incidunt cumque, delectus ullam</p>
</div>
</div>
<div class="container">
<div class="box">
<img src="./images/css3.png" alt="css3">
<h3>CSS 3 Styling</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste corrupti incidunt cumque, delectus ullam</p>
</div>
</div>
<div class="container">
<div class="box">
<img src="./images/brush.png" alt="brush">
<h3>Graphic Design</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste corrupti incidunt cumque, delectus ullam</p>
</div>
</div>
</section>
You can use display: flex in the #boxes selector in your CSS file.
If you want them to be side by side you can just use flex
#boxes {
margin-top: 20px;
display: flex;
justify-content: center;
}
You can try this:
ul {
margin: 0;
padding: 0;
}
/* Global */
.container {
width: 80%;
margin: auto;
overflow: hidden;
}
/* BOXES */
#boxes {
display: flex;
margin-top: 20px;
}
#boxes .box {
float: left;
width: 25%;
padding: 10px;
text-align: center;
}
#boxes .box img {
width: 90px;
}
<section id="boxes">
<div class="container">
<div class="box">
<img src="./images/html5.png" alt="html5">
<h3>HTML 5 Markup</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste corrupti incidunt cumque, delectus ullam</p>
</div>
</div>
<div class="container">
<div class="box">
<img src="./images/css3.png" alt="css3">
<h3>CSS 3 Styling</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste corrupti incidunt cumque, delectus ullam</p>
</div>
</div>
<div class="container">
<div class="box">
<img src="./images/brush.png" alt="brush">
<h3>Graphic Design</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste corrupti incidunt cumque, delectus ullam</p>
</div>
</div>
</section>
You can use display:flex to the #boxes. It will make its child to be in one row.
Learn more about flex https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox;
body {
/* font-family: Arial, Halvetica, sans-serif;
font-size: 15px;
line-height: 1.5em; */
font: 15px/1.5 Arial, Halvetica, sans-serif;
padding: 0;
background-color: #f4f4f4;
}
ul {
margin: 0;
padding: 0;
}
a:hover {
color: #cccccc;
}
/* Global */
.container {
width: 80%;
margin: auto;
overflow: hidden;
}
.button_1 {
height: 38px;
background: #e8491d;
border: none;
padding: 0px 20px 0px 20px;
font-style: oblique;
font-weight: bold;
color: white;
}
/*header*/
header {
background: #35424a;
color: #ffffff;
padding-top: 30px;
min-height: 70px;
border-bottom: #e8491d 3px solid;
}
header a {
color: white;
text-decoration: none;
text-transform: uppercase;
font-size: 16px;
}
header li {
float: left;
display: inline;
padding: 0 20px 0 20px;
}
header #branding {
float: left;
}
header #branding h1 {
margin: 0;
}
header nav {
float: right;
margin-top: 10px;
}
header .highlight, header .current a {
color: #e8491d;
font-weight: bold;
}
/* showcase */
#showcase {
min-height: 400px;
background: url("../images/showcase.jpg") no-repeat 0-400px;
text-align: center;
color: white;
}
#showcase h1 {
margin-top: 100px;
font-size: 55px;
margin-bottom: 10px;
}
#showcase p {
font-size: 20px;
}
/*NewsLetter */
#newsletter {
padding: 15px;
color: white;
background: #35424a;
}
#newsletter h1 {
float: left;
}
#newsletter form {
margin-top: 22px;
float: right;
}
#newsletter input[type="email"] {
padding: 4px;
height: 25px;
width: 250px;
}
/* BOXES */
#boxes {
margin-top: 20px;
display:flex;
}
#boxes .box {
width: 25%;
padding: 10px;
text-align: center;
}
#boxes .box img {
width: 90px;
}
<body>
<header>
<div class="container">
<div id="branding">
<h1><span class="highlight">Sumanyu</span> Web design</h1>
</div>
<nav>
<ul>
<li class="current">Home</li>
<li class="current">About</li>
<li class="current">Services</li>
</ul>
</nav>
</div>
</header>
<section id="showcase">
<div class= "container">
<h1>Affordable professional Web Design</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste corrupti incidunt cumque, delectus ullam aut reprehenderit debitis doloremque, necessitatibus, nulla, ab fuga reiciendis rerum culpa possimus illum labore sit laudantium.</p>
</div>
</section>
<section id="newsletter">
<div class="container">
<h1>Subscribe to Our Newsletter</h1>
<form class="process.php" action="index.html" method="post">
<input type="email" placeholder="Enter your Email">
<button type="submit" class="button_1">Subscribe</button>
</form>
</div>
</section>
<section id="boxes">
<div class="container">
<div class="box">
<img src="./images/html5.png" alt="html5">
<h3>HTML 5 Markup</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste corrupti incidunt cumque, delectus ullam</p>
</div>
</div>
<div class="container">
<div class="box">
<img src="./images/css3.png" alt="css3">
<h3>CSS 3 Styling</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste corrupti incidunt cumque, delectus ullam</p>
</div>
</div>
<div class="container">
<div class="box">
<img src="./images/brush.png" alt="brush">
<h3>Graphic Design</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste corrupti incidunt cumque, delectus ullam</p>
</div>
</div>
</section>
<footer>
<p>Sumanyu Sood Web Design, Copyright © 2020 </p>
</footer>
</body>
</html>
I'm trying to move this div to the left under the title, but I cant seem to do it with text-align or justify content, those are my usual methods for centering. However, I want this div to move to the left.
my problem
.grid-container {
max-width: 90vw;
}
.section-title {
padding: 1rem 0.5rem;
}
.title_name {
font-size: 3rem;
text-transform: capitalize;
}
.title_underline {
background: #F4D06F;
width: 15rem;
height: 0.25rem;
}
.title_text {
letter-spacing: .1rem;
line-height: 1.5;
margin-top: 1rem;
color: grey;
}
<article class="about-container">
<div class="title">
<h1 class="title_name">our story</h1>
<div class="title_underline"></div>
<p class="title_text">Lorem ipsum dolor sit amet consectetur, adipisicing elit. Saepe illo quae ea nulla quas quia eaque omnis maxime tenetur molestiae eveniet at laboriosam provident, quibusdam quo sit expedita similique earum.</p>
</div>
<div class="about_image">
<img src="img/bravo.jpg" class="about_img" alt="about-img">
</div>
</article>
<!--about column 1-->
Actually you don't need a useless extra empty <div>, just a :after pseudo:
.title_name {
font-size: 3rem;
text-transform: capitalize;
}
.title_name:after {
content: "";
display: block;
margin-top: 1rem;
background: #F4D06F;
width: 15rem;
height: 0.25rem;
}
<h1 class="title_name">our story</h1>
<p>Lorem Ipsum</p>
Because it is a div it defaults to display: block;, so you'll need to set it to display: inline-block;.
.title_underline
{
background: #F4D06F;
width: 15rem;
height: 0.25rem;
display: inline-block;
}
Currently experimenting with HTML and CSS and am struggling with this issue.
I'm messing around with a responsive website, and somehow can't make my navigation bar exceed the max-width of my navbar exceed the max-width of my content.
What I'd like it to look like https://imgur.com/a/KAk9mOi
I do really hope anyone can help me.
TIA.
<nav class="navbar">
<ul class="nav-items">
<li class="nav-item nav-item--active">Home</li>
<li class="nav-item">Contact</li>
</ul>
</nav>
.main {
}
.navbar {
padding: 20px;
background-color: #1C2826;
max-width: 100%;
}
.nav-items {
display: flex;
justify-content: center;
}
.nav-items > li {
flex: 1;
text-align: center;
}
.nav-item:not(:last-of-type) {
margin-right: 20px;
}
.nav-item--active {
/* after */
}
.content {
padding: 8px;
}
.login-card {
border: 1px solid #999;
margin-bottom: 20px;
padding: 12px;
border-radius: 4px;
}
.login {
display: flex;
flex-direction: column;
}
.login-button {
background-color: #D64550;
padding: 4px;
border: none;
color: #ffffff;
font-size: 20px;
}
.login-input {
margin-bottom: 8px;
border: none;
border-bottom: 1px solid #999;
padding-top: 4px;
padding-bottom: 4px;
}
.footer {
padding: 8px;
}
.inline-block {
display: inline-block;
}
/* Alt over 460px */
#media only screen and (min-width: 460px) {
.main{
max-width: 600px;
}
.navigation-items{
flex-wrap: wrap;
}
.login-button {
font-size: inherit;
}
}
https://jsfiddle.net/m0u79e8s/
I hope this is useful
* {
padding: 0px;
margin: 0px;
}
.main {
}
.navbar {
padding: 20px;
background-color: #1C2826;
width: 100%;
}
.nav-items {
display: flex;
justify-content: center;
}
.nav-items > li {
flex: 1;
text-align: center;
}
.nav-item:not(:last-of-type) {
margin-right: 20px;
}
.nav-item--active {
/* after */
}
.content {
padding: 8px;
}
.login-card {
border: 1px solid #999;
margin-bottom: 20px;
padding: 12px;
border-radius: 4px;
}
.login {
display: flex;
flex-direction: column;
}
.login-button {
background-color: #D64550;
padding: 4px;
border: none;
color: #ffffff;
font-size: 20px;
}
.login-input {
margin-bottom: 8px;
border: none;
border-bottom: 1px solid #999;
padding-top: 4px;
padding-bottom: 4px;
}
.footer {
padding: 8px;
}
.inline-block {
display: inline-block;
}
/* Alt over 460px */
#media only screen and (min-width: 460px) {
.main {
display: flex;
flex-direction: column;
align-items: center;
}
.content {
max-width: 460px;
}
.navigation-items{
flex-wrap: wrap;
}
.login-button {
font-size: inherit;
}
}
<!doctype html>
<html>
<head>
<title>Responsive time</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Raleway:400,600,700" rel="stylesheet">
<link rel="stylesheet" href="./reset.css">
<link rel="stylesheet" href="./generic.css">
<link rel="stylesheet" href="./styles.css">
</head>
<html>
<body>
<main class="main">
<!-- Navigation elements -->
<nav class="navbar">
<ul class="nav-items">
<li class="nav-item nav-item--active">Home</li>
<li class="nav-item">Contact</li>
</ul>
</nav>
<!-- Section -->
<section class="content">
<h1 class="test">Time to get responsive</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Labore deleniti, quia provident!</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis quas alias reiciendis velit, dolor eos temporibus culpa ex modi itaque nostrum natus doloribus sed maiores, a obcaecati quia sequi quisquam corrupti perspiciatis sit quam, qui expedita. Nemo sed dolor earum voluptate quod reiciendis rem laborum atque ex nulla sapiente ea ullam assumenda, fugiat quae incidunt dicta, cupiditate repellendus possimus aliquid! Ad veniam vero alias, rem quod atque dolores saepe possimus, tempora, eaque magnam culpa animi repellendus ratione dolorem harum quo.</p>
<!-- Form -->
<div class="login-card">
<form class="login" action="#" method="get">
<input class="login-input" type="email" placeholder="Indtast email">
<input class="login-input" type="password" placeholder="Indtast kodeord">
<button class="login-button">Send</button>
</form>
</div>
<picture>
<source media="(max-width:459px)" srcset="img/cow.jpg">
<source media="(min-width:460px)" srcset="img/dog.jpg">
<img src="/img/cow.jpg" alt="animals">
</picture>
</section>
<footer class="footer">
<div class="footer-content">
<p>Lorem ipsum dolor sit amet.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit quas beatae voluptate.</p>
Some other link
</div>
<div class="footer-content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Modi!</p>
<img class="logo-image" src="/rubbish" alt="">
</div>
</footer>
</main>
</body>
</html>
</html>
Simply in Facebook style, I'd like to do something like this:
I've used CSS flex but I am able to do only in row, not columns.
Total width is the fix dimension, total height and column width have to scale and cover all area. Images have to keep aspect ratio.
My code works with 2 rows. I want the same result with images in columns.
<style>
#main{
width:640px;
margin: 0 auto;
}
.flex-row1, .flex-row2 {
display: flex;
flex-direction: row;
}
.inner {
flex: 1 1 auto;
padding: 0;
margin: 0;
margin-right:2px;
}
.inner.last {
margin-right:0;
position:relative;
}
.flex-row1 .inner{
margin-bottom:2px;
}
img {
max-width:100%;
max-height: 250px;
}
.more-container {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.4);
display: flex;
align-items: center;
justify-content: center;
}
.more {
font-family: Tahoma, Geneva, sans-serif;
color: #fff;
font-size: 30px;
}
</style>
<div id="main">
<div class="flex-row1">
<figure class="inner">
<img src="https://www.wemedia.it/cms/wp-content/uploads/2017/03/commodore64-android-640x283.jpg">
</figure>
<figure class="inner last">
<img src="https://www.wemedia.it/cms/wp-content/uploads/2017/02/Esslinger-Frog-Design-Apple-1982-640x480.jpg">
</figure>
</div>
<div class="flex-row2">
<figure class="inner">
<img src="https://www.wemedia.it/cms/wp-content/uploads/2017/04/commodore64-silver-label-640x435.jpg">
</figure>
<figure class="inner">
<img src="https://www.wemedia.it/cms/wp-content/uploads/2017/04/commodore64_sx.jpg">
</figure>
<figure class="inner last">
<img src="https://www.wemedia.it/cms/wp-content/uploads/2017/04/C64_golden_edition-640x500.jpg">
<div class="more-container"><div class="more">+3</div></div>
</figure>
</div>
</div>
.equal-height-container {
max-width: 900px;
margin: 0 auto;
display: flex;
}
.first {
background-color: yellow;
flex: 1;
display: flex;
flex-direction: column;
}
.first-a {
background-color: blue;
flex: 1;
}
.first-b {
background-color: orange;
flex: 1;
}
.second {
background-color: yellow;
flex: 1;
display: flex;
flex-direction: column;
}
.second-a {
background-color: #c0dbe2;
flex: 1;
}
.second-b {
background-color: #cdf1c3;
flex: 1;
}
.second-c {
background-color: red;
flex: 1;
}
<div class="equal-height-container">
<div class="first">
<div class="first-a"> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsam quasi similique amet voluptatem molestiae nostrum ab nesciunt blanditiis repellendus quos, sequi sunt, dolorem quis facilis mollitia nemo modi doloribus quo.</p></div>
<div class="first-b"> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Placeat quisquam, veritatis ducimus, vero magnam hic quia pariatur asperiores laudantium quod nobis perspiciatis, expedita quo reprehenderit quasi iusto ullam error reiciendis.</p></div>
</div>
<div class="second">
<div class="second-a">A</div>
<div class="second-b">B</div>
<div class="second-c">C</div>
</div>
</div>