I am trying to create a few block/box with image and two text - headline and subtext, but headline sometimes has one sentence, but another more, so if one has one and second one has two I would like to center vertically this first one.
For subtext I would like to vertically to the top.
Here is code which I am trying to use:
<div class="row row-home">
<div class="col-sm-4">
<img src="/images/home-1.png" alt="Schody" class="center-block img-responsive" />
<div class="text">
<h2>Schody</h2>
<h3>Lorem ipsum dolor sit amet, consectetur adipi scing elit. Nulla volut pat sem id turpis tempus efficitur. Maecenas eu bibendum sem.</h3>
</div>
</div>
<div class="col-sm-4">
<img src="/images/home-2.png" alt="Balustrady" class="center-block img-responsive" />
<div class="text">
<h2>Balustrady i ogrodzenia</h2>
<h3>Lorem ipsum dolor sit amet, consectetur adipi scing elit. Nulla volut pat sem id turpis tempus efficitur. Maecenas eu bibendum sem.</h3>
</div>
</div>
<div class="col-sm-4">
<img src="/images/home-3.png" alt="Meble" class="center-block img-responsive" />
<div class="text">
<h2>Meble</h2>
<h3>Lorem ipsum dolor sit amet, consectetur adipi scing elit. Nulla volut pat sem id turpis tempus efficitur. Maecenas eu bibendum sem.</h3>
</div>
</div>
</div>
Here is CSS:
#home .text {
display: flex;
flex-direction: column;
-ms-flex-direction: column;
position: relative;
text-align: center;
padding: 10px 20px 30px;
margin: 0px auto 40px;
width: 100%;
height: 100%;
max-width: 236px;
z-index: 1;
}
#home .text h2 {
display: flex;
flex-direction: column;
-ms-flex-direction: column;
justify-content: center;
flex: 1 0 auto;
position: relative;
color: white;
font-size: 14px;
font-weight: bold;
text-transform: uppercase;
margin-top: 40px;
margin-bottom: 0px;
z-index: 2;
}
#home .text h3 {
position: relative;
color: white;
font-size: 12px;
text-align: justify;
text-transform: uppercase;
text-align-last: center;
z-index: 2;
}
It almost work, but if h3 has less text in one of blocks this text align to the bottom and h2 goes down.
Here is live website to test
I create picture to show how it should work
Since the h2 elements aren't aware of each other, I suggest you give them a height, or else you will need a extensive markup change
Here I added height: 28px; to the .row-home .text h2 rule
.row-home .text {
display: flex;
flex-direction: column;
-ms-flex-direction: column;
position: relative;
text-align: center;
padding: 10px 20px 30px;
margin: 0px auto 40px;
width: 100%;
height: 100%;
max-width: 236px;
z-index: 1;
}
.row-home .text h2 {
display: flex;
flex-direction: column;
-ms-flex-direction: column;
justify-content: center;
flex: 1 0 auto;
position: relative;
color: white;
font-size: 14px;
height: 28px;
font-weight: bold;
text-transform: uppercase;
margin-top: 40px;
margin-bottom: 0px;
z-index: 2;
}
.row-home .text h3 {
position: relative;
color: white;
font-size: 12px;
text-align: justify;
text-transform: uppercase;
text-align-last: center;
z-index: 2;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row row-home">
<div class="col-sm-4">
<img src="http://malykowal.linuxpl.eu/images/home-1.png" alt="Schody" class="center-block img-responsive" />
<div class="text">
<h2>Schody</h2>
<h3>Lorem ipsum dolor sit amet, consectetur adipi scing elit. Nulla volut pat sem id turpis tempus efficitur. Maecenas eu bibendum sem.</h3>
</div>
</div>
<div class="col-sm-4">
<img src="http://malykowal.linuxpl.eu/images/home-1.png" alt="Balustrady" class="center-block img-responsive" />
<div class="text">
<h2>Balustrady i ogrodzenia</h2>
<h3>Lorem ipsum dolor sit amet, consectetur adipi scing elit. Nulla volut pat sem id turpis tempus efficitur. Maecenas eu bibendum sem.</h3>
</div>
</div>
<div class="col-sm-4">
<img src="http://malykowal.linuxpl.eu/images/home-1.png" alt="Meble" class="center-block img-responsive" />
<div class="text">
<h2>Meble</h2>
<h3>Lorem ipsum dolor sit amet, consectetur adipi scing elit. Nulla volut pat sem id turpis tempus efficitur. Maecenas eu bibendum sem.</h3>
</div>
</div>
</div>
</div>
Updated with a second version based on a comment
If you want this to be really dynamic, you'll need to break it down like this, where you make the col-sm-4 flex items
Updated again, with a media query, to utilize Flexbox's order property and re-position the elements on smaller screens
.row-home {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.row-home .col-sm-4 {
min-width: 0;
flex-basis: 33%;
padding: 10px 20px 30px;
}
.row-home .col-sm-4.vcentered {
align-self: center;
}
.row-home .col-sm-4 h2 {
font-size: 14px;
font-weight: bold;
text-transform: uppercase;
}
.row-home .col-sm-4 h3 {
font-size: 12px;
text-align: justify;
text-transform: uppercase;
text-align-last: center;
}
#media (max-width: 600px) {
.row-home .col-sm-4 {
flex-basis: 51%;
}
.row-home .col-sm-4 * {
text-align: center;
}
.row-home .col-sm-4:nth-child(3n+1) {
order: 1;
}
.row-home .col-sm-4:nth-child(3n+2) {
order: 2;
}
.row-home .col-sm-4:nth-child(3n+3) {
order: 3;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row row-home">
<div class="col-sm-4">
<img src="http://malykowal.linuxpl.eu/images/home-1.png" alt="Schody" class="center-block img-responsive" />
</div>
<div class="col-sm-4">
<img src="http://malykowal.linuxpl.eu/images/home-1.png" alt="Balustrady" class="center-block img-responsive" />
</div>
<div class="col-sm-4">
<img src="http://malykowal.linuxpl.eu/images/home-1.png" alt="Meble" class="center-block img-responsive" />
</div>
<div class="col-sm-4 vcentered">
<h2>Schody this is some extra text I added for test</h2>
</div>
<div class="col-sm-4 vcentered">
<h2>Balustrady i ogrodzenia</h2>
</div>
<div class="col-sm-4 vcentered">
<h2>Meble</h2>
</div>
<div class="col-sm-4">
<h3>Lorem ipsum dolor sit amet, consectetur adipi scing elit.</h3>
</div>
<div class="col-sm-4">
<h3>Lorem ipsum dolor sit amet, consectetur adipi scing elit. Nulla volut pat sem id turpis tempus efficitur. Maecenas eu bibendum sem.</h3>
</div>
<div class="col-sm-4">
<h3>Lorem ipsum dolor sit amet, consectetur adipi scing elit. Nulla volut pat sem id turpis tempus efficitur. Maecenas eu bibendum sem.</h3>
</div>
</div>
</div>
Related
I'm fairly new to software engineering! I'm having quite some trouble horizontally aligning my navigation bar to the center for my desktop view? I'm currently learning how to utilize bootstrap! I'm sure I have to include a container div somewhere, just not sure! Any help is help! Thanks! Here is my website preview: https://frontendfoundations.marlenebarr.repl.co/
body {
font-family: "Lato", sans-serif;
}
h2 {
font-size: clamp(14px, -1rem + 8.333vw, 26px);
color: #fff;
font-weight: 400;
margin: 0 10px 10px 10px;
text-align: center;
}
h3 {
font-size: 18px;
font-weight: 500;
}
p {
line-height: 1.5em;
margin: 0;
}
section {
padding: 20px;
}
section.alternate-background {
background-color: #00a699;
color: #fff;
}
main img {
width: 100%;
}
.dark {
color: black;
}
/* --- Groups & Items --- */
.group {
display: flex;
flex-direction: column;
}
.item {
flex: 1;
margin: 10px;
}
.item-double {
flex: 2;
}
/* ------- Navigation ------- */
header {
background-color: #ff385c;
padding: 20px 20px 0 20px;
text-align: center;
}
.logo {
font-family: "Pangolin", cursive;
font-size: clamp(24px, -1rem + 8.333vw, 72px);
color: #fff;
}
header nav {
display: flex;
justify-content: center;
}
header nav ul {
display: flex;
flex-wrap: wrap;
}
header nav ul li {
list-style-type: none;
}
header nav ul li a {
color: #fff;
text-decoration: none;
padding: 0 20px 0 0;
}
header nav ul li a:hover {
color: #bdbdbd;
text-decoration: none;
}
/* ------- Search Form ------- */
form {
border: 2px solid #ff385c;
padding: 10px;
}
form label {
font-weight: bold;
}
form select,
form input {
margin-bottom: 20px;
width: 180px;
}
form button {
background-color: #ff385c;
border: none;
color: #fff;
font-size: 24px;
padding: 15px;
width: 100%;
}
form div {
display: flex;
justify-content: space-between;
}
/* ------- Footer ------- */
footer {
background-color: #ff385c;
}
footer p {
color: #fff;
text-align: center;
padding: 20px;
}
/* ------- Media Query ------- */
#media all and (min-width: 480px) {
/* ------ General ------ */
p {
padding: 10px;
}
.group-lg {
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
}
/* ------ Navigation ------ */
header {
display: flex;
justify-content: space-between;
}
header div {
display: flex;
align-items: center;
}
/* ------ Form -----*/
form {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
form div {
display: flex;
flex-direction: column;
padding: 10px;
}
form button {
margin: 10px;
width: 100%;
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" rel="stylesheet" type="text/css" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link href="https://fonts.googleapis.com/css2?family=Pangolin&family=Lato&display=swap" rel="stylesheet" />
<header>
<div class="logo">Thinkfulbnb</div>
<nav>
<ul id="menu">
<li>Stay</li>
<li>About</li>
<li>Ideas</li>
<li>Host</li>
</ul>
</nav>
</header>
<main>
<!-- Stay -->
<section id="stay">
<h2>Find the perfect vacation rental</h2>
<!-- Create a form here -->
<form>
<div class="form-lg">
<label for="location">Location</label>
<input id="location" ; type="text" placeholder="Search Destination" required />
</div>
<div class="form-lg">
<label for="arrive">Arrive</label>
<input id="arrive" ; type="date" required />
</div>
<div class="form-lg">
<label for="depart">Depart</label>
<input id="depart" ; type="date" required />
</div>
<div class="form-lg">
<label for="type">Type</label>
<select name="type" id="type" size="1">
<option value="apartment">Apartment</option>
<option value="barn">Barn</option>
<option value="castle">Castle</option>
<option value="houseboat">Houseboat</option>
<option value="tiny-house">Tiny House</option>
<option value="yacht">Yacht</option>
<option value="yurt">Yurt</option>
</select>
</div>
<div>
<button type="submit" class="form-lg">Search</button>
</div>
</form>
</section>
<!-- About -->
<section id="about" class="alternate-background">
<h2>About</h2>
<div class="group-lg">
<div class="item">
<img src="vacation-rental-pool.png" alt="Thinkfulbnb - Vacation rental pool" />
</div>
<div class="item">
<img src="vacation-rental-inside-stone.png" alt="Thinkfulbnb - Vacation rental inside stone" />
</div>
<div class="item-double">
<p>
Fusce porta odio nunc, eget pretium massa rutrum sit amet. Etiam fringilla aliquam dapibus. Maecenas quis nisi sed turpis aliquam porttitor eget ut quam. Sed vel scelerisque ex. Duis in pharetra neque, at tempus lorem. Aenean mi magna, posuere at quam
sed, euismod gravida neque.
</p>
</div>
</div>
</section>
<!-- Ideas -->
<section id="ideas">
<h2 class="dark">Ideas</h2>
<div class="group-lg">
<div class="item">
<h3>Forest retreats</h3>
<img src="forest-retreat.png" alt="Thinkfulbnb - Forest retreat" />
</div>
<div class="item">
<h3>Beaches</h3>
<img src="beach-house.png" alt="Thinkfulbnb - Beach house" />
</div>
</div>
<div class="group-lg">
<div class="item">
<h3>Rustic cabins</h3>
<img src="cabin.png" alt="Thinkfulbnb - Cabin" />
</div>
<div class="item">
<h3>Pet-friendly</h3>
<img src="pet-friendly.png" alt="Thinkfulbnb - Pet-friendly" />
</div>
</div>
</section>
<!-- Host -->
<section id="host" class=" group-lg alternate-background">
<div class="item">
<h2>Want to Become a Thinkfulbnb Host?</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus molestie in est id efficitur. Sed hendrerit ut turpis quis dapibus. Nam sit amet iaculis lectus. Aliquam erat volutpat. Praesent rhoncus pellentesque eros in aliquet. Sed accumsan elit
lacus, id ultrices libero rutrum vitae.
</p>
<ul>
<li>Mauris in pellentesque ligula.</li>
<li>Sed accumsan elit lacus, id ultrices libero rutrum vitae.</li>
<li>Nunc vitae ex eget neque pellentesque porttitor.</li>
<li>Cras mollis lorem sagittis sapien imperdiet blandit. Vivamus.</li>
<li>
Donec vehicula ipsum nisi, eu consectetur leo feugiat et. Fusce eget hendrerit mauris.
</li>
</ul>
</div>
<div class="item">
<img src="become-a-host.png" alt="Thinkfulbnb - Become a host" />
</div>
</section>
</main>
<footer>
<p>© Thinkful</p>
</footer>
add this simple CSS code, and will hopefully solve that issue in desktop version.
form {
display: flex;
justify-content: center;
}
if you want, you can also add also this code on the mobile version, outside #media, which is also a good design on mobile!
justify-content docs link: https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content
body {
font-family: "Lato", sans-serif;
}
h2 {
font-size: clamp(14px, -1rem + 8.333vw, 26px);
color: #fff;
font-weight: 400;
margin: 0 10px 10px 10px;
text-align: center;
}
h3 {
font-size: 18px;
font-weight: 500;
}
p {
line-height: 1.5em;
margin: 0;
}
section {
padding: 20px;
}
section.alternate-background {
background-color: #00a699;
color: #fff;
}
main img {
width: 100%;
}
.dark {
color: black;
}
/* --- Groups & Items --- */
.group {
display: flex;
flex-direction: column;
}
.item {
flex: 1;
margin: 10px;
}
.item-double {
flex: 2;
}
/* ------- Navigation ------- */
header {
background-color: #ff385c;
padding: 20px 20px 0 20px;
text-align: center;
}
.logo {
font-family: "Pangolin", cursive;
font-size: clamp(24px, -1rem + 8.333vw, 72px);
color: #fff;
}
header nav {
display: flex;
justify-content: center;
}
header nav ul {
display: flex;
flex-wrap: wrap;
}
header nav ul li {
list-style-type: none;
}
header nav ul li a {
color: #fff;
text-decoration: none;
padding: 0 20px 0 0;
}
header nav ul li a:hover {
color: #bdbdbd;
text-decoration: none;
}
/* ------- Search Form ------- */
form {
border: 2px solid #ff385c;
padding: 10px;
/* what I added to center it */
display: flex;
justify-content: center;
}
form label {
font-weight: bold;
}
form select,
form input {
margin-bottom: 20px;
width: 180px;
}
form button {
background-color: #ff385c;
border: none;
color: #fff;
font-size: 24px;
padding: 15px;
width: 100%;
}
form div {
display: flex;
justify-content: space-between;
}
/* ------- Footer ------- */
footer {
background-color: #ff385c;
}
footer p {
color: #fff;
text-align: center;
padding: 20px;
}
/* ------- Media Query ------- */
#media all and (min-width: 480px) {
/* ------ General ------ */
p {
padding: 10px;
}
.group-lg {
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
}
/* ------ Navigation ------ */
header {
display: flex;
justify-content: space-between;
}
header div {
display: flex;
align-items: center;
}
/* ------ Form -----*/
form {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
form div {
display: flex;
flex-direction: column;
padding: 10px;
}
form button {
margin: 10px;
width: 100%;
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width initital-scale=1" />
<title>Vacation Rentals & Unique Homes</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" rel="stylesheet" type="text/css" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link href="https://fonts.googleapis.com/css2?family=Pangolin&family=Lato&display=swap" rel="stylesheet" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<header>
<div class="logo">Thinkfulbnb</div>
<nav>
<ul id="menu">
<li>Stay</li>
<li>About</li>
<li>Ideas</li>
<li>Host</li>
</ul>
</nav>
</header>
<main>
<!-- Stay -->
<section id="stay">
<h2>Find the perfect vacation rental</h2>
<!-- Create a form here -->
<form>
<div class="form-lg">
<label for="location">Location</label>
<input id="location" ; type="text" placeholder="Search Destination" required />
</div>
<div class="form-lg">
<label for="arrive">Arrive</label>
<input id="arrive" ; type="date" required />
</div>
<div class="form-lg">
<label for="depart">Depart</label>
<input id="depart" ; type="date" required />
</div>
<div class="form-lg">
<label for="type">Type</label>
<select name="type" id="type" size="1">
<option value="apartment">Apartment</option>
<option value="barn">Barn</option>
<option value="castle">Castle</option>
<option value="houseboat">Houseboat</option>
<option value="tiny-house">Tiny House</option>
<option value="yacht">Yacht</option>
<option value="yurt">Yurt</option>
</select>
</div>
<div>
<button type="submit" class="form-lg">Search</button>
</div>
</form>
</section>
<!-- About -->
<section id="about" class="alternate-background">
<h2>About</h2>
<div class="group-lg">
<div class="item">
<img src="vacation-rental-pool.png" alt="Thinkfulbnb - Vacation rental pool" />
</div>
<div class="item">
<img src="vacation-rental-inside-stone.png" alt="Thinkfulbnb - Vacation rental inside stone" />
</div>
<div class="item-double">
<p>
Fusce porta odio nunc, eget pretium massa rutrum sit amet. Etiam fringilla aliquam dapibus. Maecenas quis nisi sed turpis aliquam porttitor eget ut quam. Sed vel scelerisque ex. Duis in pharetra neque, at tempus lorem. Aenean mi magna, posuere at quam
sed, euismod gravida neque.
</p>
</div>
</div>
</section>
<!-- Ideas -->
<section id="ideas">
<h2 class="dark">Ideas</h2>
<div class="group-lg">
<div class="item">
<h3>Forest retreats</h3>
<img src="forest-retreat.png" alt="Thinkfulbnb - Forest retreat" />
</div>
<div class="item">
<h3>Beaches</h3>
<img src="beach-house.png" alt="Thinkfulbnb - Beach house" />
</div>
</div>
<div class="group-lg">
<div class="item">
<h3>Rustic cabins</h3>
<img src="cabin.png" alt="Thinkfulbnb - Cabin" />
</div>
<div class="item">
<h3>Pet-friendly</h3>
<img src="pet-friendly.png" alt="Thinkfulbnb - Pet-friendly" />
</div>
</div>
</section>
<!-- Host -->
<section id="host" class="group-lg alternate-background">
<div class="item">
<h2>Want to Become a Thinkfulbnb Host?</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus molestie in est id efficitur. Sed hendrerit ut turpis quis dapibus. Nam sit amet iaculis lectus. Aliquam erat volutpat. Praesent rhoncus pellentesque eros in aliquet. Sed accumsan elit
lacus, id ultrices libero rutrum vitae.
</p>
<ul>
<li>Mauris in pellentesque ligula.</li>
<li>Sed accumsan elit lacus, id ultrices libero rutrum vitae.</li>
<li>Nunc vitae ex eget neque pellentesque porttitor.</li>
<li>
Cras mollis lorem sagittis sapien imperdiet blandit. Vivamus.
</li>
<li>
Donec vehicula ipsum nisi, eu consectetur leo feugiat et. Fusce eget hendrerit mauris.
</li>
</ul>
</div>
<div class="item">
<img src="become-a-host.png" alt="Thinkfulbnb - Become a host" />
</div>
</section>
</main>
<footer>
<p>© Thinkful</p>
</footer>
</body>
</html>
I am trying to write a responsive footer. The footer items are separated by vertical bar (|). When we decrease the screen size, the footer items are wrapping to second line. Vertical bar (|) needs to be only between the footer items. Also facebook logo needs to be on the same line with the footer items for bigger screen sizes and on the center for smaller screen sizes. I used float:right but now they wrap from the beginning. How can I make them wrap from the end and hide vertical bar (|) if it is not between the footer items?
Here is my source code: https://jsfiddle.net/6kcdvteo/
body {
font-family: 'Calibri';
}
.text {
font-size: 1rem;
padding: 1rem 1rem 2rem 2rem;
color: #666666;
background-color: #f4f4f4;
}
.footer {
font-size: 0.85rem;
padding: 2rem 1rem 2rem 2rem;
background-color: #303741;
color: white;
}
.footer_company {
float: right;
padding-right: 2rem;
}
.footer_links {
font-size: 0.85rem;
background-color: #303741;
color: white;
padding-bottom: 2rem;
padding-right: 2.5rem;
}
.footer_links_span span {
background-color: #303741;
padding-right: 0.5rem;
float: right;
}
img {
height: 3rem;
width: 3rem;
}
.img {
padding-left: 1rem;
display: inline-block;
}
<div class="text">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras ac cursus felis, ut egestas lacus. Sed nec elementum ipsum. Morbi metus est, venenatis at libero pharetra, suscipit posuere dolor. Proin a auctor nulla, sed tincidunt tellus. Nullam bibendum
luctus elit, sed porttitor lectus varius in. Cras venenatis rutrum urna at ultrices. Sed in luctus ligula.
</p>
</div>
<div class="footer">
<span class="footer_company">© My Company Name</span>
</div>
<div class="footer_links">
<div class="img">
<img src="https://image.flaticon.com/icons/png/512/124/124010.png">
</div>
<div class="footer_links_span">
<span>Sed metus</span>
<span>|</span>
<span>Aenean ultricies</span>
<span>|</span>
<span>Praesent vitae</span>
<span>|</span>
<span>Donec auctor</span>
<span>|</span>
<span>Vestibulum lobortis</span>
</div>
</div>
As part of your question you can use this
<div class="footer_links">
<div class="img">
<img src="https://image.flaticon.com/icons/png/512/124/124010.png" alt="">
</div>
<div class="footer_links_span">
<span><b>|</b> Sed metus</span>
<span><b>|</b> Aenean ultricies</span>
<span><b>|</b> Praesent vitae</span>
<span><b>|</b> Donec auctor</span>
<span><b>|</b> Vestibulum lobortis <b>|</b></span>
</div>
</div>
with this css
/* container */
.footer_links {
padding: 0.75rem 1.5rem;
font-size: 0.85rem;
background-color: #303741;
color: white;
}
/* clearfix floats */
.footer_links::after {
display: block;
clear: both;
content: "";
}
/* facebook img */
.img {
float: left;
}
.img img {
width: 3rem;
height: auto;
border: 0;
}
/* links */
.footer_links_span {
float: right;
width: calc(100% - 3.5rem);
text-align: right;
}
.footer_links_span span {
display: inline-block;
white-space: nowrap;
background-color: #303741;
}
.footer_links b {
padding: 0 0.2rem;
font-weight: inherit;
}
.footer_links_span span:first-child b {
padding-left: 0;
}
.footer_links_span span:last-child b {
padding-right: 0;
}
Maybe it will help you in the right direction.
This will solve your problem, but it's Bootstrap :) All your responsive screenshotes are implemented in this code. No extra css for the layout required.
EDIT: The included style is for the width of the links block and for hiding the pipe symbool on small screens.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Page</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<style type="text/css">
#footerSocial img { width: 3rem; margin-bottom: 0.5rem; }
#footerLinks > div { max-width: 350px; margin: auto; }
#footerLinks .dv { font-weight: inherit; display: none; }
#media (min-width: 576px) {
#footerSocial img { margin-bottom: 0; }
#footerLinks > div { max-width: none; padding-left: 100px; }
}
#media (min-width: 768px) {
#footerLinks > div { padding-left: 0; }
#footerLinks .dv { display: inline; }
}
</style>
</head>
<body>
<div class="container-fluid bg-secondary text-white">
<div class="row py-3">
<div class="col-12 text-center">
<h1 class="mb-2">Company Name</h1>
</div>
</div>
</div>
<div class="container">
<div class="row py-3">
<div class="col-12 ">
<h2>Article</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras ac cursus felis, ut egestas lacus.
Sed nec elementum ipsum. Morbi metus est, venenatis at libero pharetra, suscipit posuere dolor.
Proin a auctor nulla, sed tincidunt tellus. Nullam bibendum luctus elit, sed porttitor lectus
varius in. Cras venenatis rutrum urna at ultrices. Sed in luctus ligula.</p>
</div>
</div>
</div>
<div class="container-fluid bg-dark text-white">
<div class="row px-2 py-3">
<div id="footerSocial" class="col-12 col-sm-2 text-center text-sm-left">
<img class="img-fluid bg-white" src="https://image.flaticon.com/icons/png/512/124/124010.png" alt="FB">
</div>
<div id="footerLinks" class="col-12 col-sm-10 text-center text-sm-right">
<div>
© Company Name<br>
<span class="text-nowrap">Sed metus</span>
<span class="text-nowrap">| Aenean ultricies</span>
<span class="text-nowrap">| Praesent vitae</span>
<span class="text-nowrap"><b class="dv">| </b>Donec auctor</span>
<span class="text-nowrap">| Vestibulum lobortis</span>
</div>
</div>
</div>
</div>
</body>
</html>
The boxes on the services page aren't centered and aren't full width.
I have tried changing the margin to 0 auto location, I have also tried align-content: center:
ul#services li {
list-style: none;
padding: 20px;
border: #cccccc solid 1px;
margin-bottom: 5px;
background: #e6e6e6;
}
.page-title {
font-family: Playfair Display;
font-size: 18px;
}
#media (max-width: 768px) {
header#bradning,
header nav,
header nav li,
#newsletter h1,
#newsletter h1,
#newsletter form,
#boxes .box,
article#main-col,
aside#sidebar,
ul#services,
main {
float: none;
text-align: center;
width: 100%;
font-size: 14px;
margin: 0 auto;
}
header {
padding-bottom: 20px;
}
#showcase h1 {
margin-top: 40px;
}
#newsletter h1 {
text-align: center;
font-size: 24px;
}
#newsletter button,
#sidebar-quote button {
display: block;
width: 100%;
}
#newsletter form input[type="email"],
#sidebar-quote input,
#sidebar-quote textarea {
width: 100%;
margin-bottom: 5px;
}
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<section id="main">
<div class="container">
<article id="main-col">
<h1 class="page-title">Services</h1>
<ul id="services">
<li>
<h3>Website Design</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus mi augue, viverra sit amet ultricies at, vulputate id lorem. Nulla facilisi.</p>
<p>Pricing: $1,000 - $3,000</p>
</li>
<li>
<h3>Website Maintenance</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus mi augue, viverra sit amet ultricies at, vulputate id lorem. Nulla facilisi.</p>
<p>Pricing: $250 per month</p>
</li>
<li>
<h3>Website Hosting</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus mi augue, viverra sit amet ultricies at, vulputate id lorem. Nulla facilisi.</p>
<p>Pricing: $25 per month</p>
</li>
</ul>
</article>
<aside id="sidebar">
<div class="dark">
<h3>Get A Quote</h3>
<form class="quote">
<div>
<label>Name</label><br>
<input type="text" placeholder="Name">
</div>
<div>
<label>Email</label><br>
<input type="email" placeholder="Emial Address">
</div>
<div>
<label>Message</label><br>
<textarea placeholder="Message"></textarea>
</div>
<button class="button_1" type="submit">Send</button>
</form>
</div>
</aside>
</div>
</section>
I expect the boxes to be centered and the same width as the get a quote section.
If anyone can help with this issue that would be great I am not sure what to do next, the site is functional as is but doesn't look as good as I was hoping.
you want it like this right?
I just set some css property to ul#services see below
#services{padding: 0;display: block; margin: 0 auto;}
ul#services li {
list-style: none;
padding: 20px;
border: #cccccc solid 1px;
margin-bottom: 5px;
background: #e6e6e6;
}
#services {
padding: 0;
display: block;
margin: 0 auto;
}
.page-title {
font-family: Playfair Display;
font-size: 18px;
}
#media (max-width: 768px) {
header#bradning,
header nav,
header nav li,
#newsletter h1,
#newsletter h1,
#newsletter form,
#boxes .box,
article#main-col,
aside#sidebar,
ul#services,
main {
float: none;
text-align: center;
width: 100%;
font-size: 14px;
margin: 0 auto;
}
header {
padding-bottom: 20px;
}
#showcase h1 {
margin-top: 40px;
}
#newsletter h1 {
text-align: center;
font-size: 24px;
}
#newsletter button,
#sidebar-quote button {
display: block;
width: 100%;
}
#newsletter form input[type="email"],
#sidebar-quote input,
#sidebar-quote textarea {
width: 100%;
margin-bottom: 5px;
}
}
<section id="main">
<div class="container">
<article id="main-col">
<h1 class="page-title">Services</h1>
<ul id="services">
<li>
<h3>Website Design</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus mi augue, viverra sit amet ultricies at, vulputate id lorem. Nulla facilisi.</p>
<p>Pricing: $1,000 - $3,000</p>
</li>
<li>
<h3>Website Maintenance</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus mi augue, viverra sit amet ultricies at, vulputate id lorem. Nulla facilisi.</p>
<p>Pricing: $250 per month</p>
</li>
<li>
<h3>Website Hosting</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus mi augue, viverra sit amet ultricies at, vulputate id lorem. Nulla facilisi.</p>
<p>Pricing: $25 per month</p>
</li>
</ul>
</article>
<aside id="sidebar">
<div class="dark">
<h3>Get A Quote</h3>
<form class="quote">
<div>
<label>Name</label><br>
<input type="text" placeholder="Name">
</div>
<div>
<label>Email</label><br>
<input type="email" placeholder="Emial Address">
</div>
<div>
<label>Message</label><br>
<textarea placeholder="Message"></textarea>
</div>
<button class="button_1" type="submit">Send</button>
</form>
</div>
</aside>
</div>
</section>
I want to add a number to the top left corner of my div's, but whatever I have tried so far has not worked properly.
Here is what I currently have:
Here is what I would like:
Here is the code:
#Office365, #OneDrive {
height: 100px;
width: 16.259%;
display: flex;
align-items: center;
justify-content: center;
margin-right: 5px;
background-color: #F2F2F2;
}
<div class="row" id="firstAppRow">
<div class="col-sm-2" id="Office365" style="padding-top: 20px; font-weight: bold;">
<span>1</span>
<div><img src="/TrainingResourceCenter/O365Training/PublishingImages/OVbiWcG.png" height="50px" width="50px" />
<p>Office365</p>
</div>
</div>
<div class="col-sm-2" id="OneDrive" style="padding-top: 20px; font-weight: bold;">
<div><img src="/TrainingResourceCenter/O365Training/PublishingImages/wJAtQYP.png" height="40px" width="40px" />
<p>OneDrive</p>
</div>
</div>
</div>
He, the solution will be to use absolute position for the numbers.
Note that the blocks containing the tag with the number will need to be positioned relative so that the numbers are absolute to that block. Here is a sample code
#Office365,#OneDrive{
display: inline-block;
margin-right: 2px;
background-color: #F2F2F2;
position:relative;
border:1px solid black;
padding: 0 50px;
text-align: center;
}
#Office365 img,#OneDrive img{
width:100px;
height: auto;
}
.num{
position: absolute;
top: 5px;
left: 5px;
}
<div class="row" id="firstAppRow">
<div class="col-sm-2" id="Office365" style="padding-top: 20px; font-weight: bold;">
<div><img src="https://png.icons8.com/color/1600/office-365.png" height="50px" width="50px" />
<p>Office365</p>
<span class="num">1</span>
</div>
</div>
<div class="col-sm-2" id="OneDrive" style="padding-top: 20px; font-weight: bold;">
<div><img src="https://bcpsodl.pbworks.com/f/1477585037/onedrive.png" height="40px" width="40px" />
<p>OneDrive</p>
<span class="num">2</span>
</div>
</div>
</div>
Try assigning
position: relative;
to the #Office365 and #OneDrive. Also put the images inside those divs.
Then assign
position: absolute;
left: 1px;
top: 1px;
to #Office365 span and #OneDrive span.
absolute vs float
.a {
width: 200px;
position: relative;
border: 1px solid gray;
margin-right:20px;
display:inline-block;
vertical-align:top;
}
.viaAbsolute {
position: absolute;
top:0;
left: 0;
padding: 3px;
border: 1px solid red;
}
.viaFloat {
float: left;
padding: 3px;
border: 1px solid red;
}
<div class="a">
<span class="viaAbsolute">
1
</span> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam tempus rhoncus quam quis vestibulum. Cras eu mollis nisl. Pellentesque semper tincidunt placerat.
</div>
<div class="a">
<span class="viaFloat">
1
</span> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam tempus rhoncus quam quis vestibulum. Cras eu mollis nisl. Pellentesque semper tincidunt placerat.
</div>
https://jsfiddle.net/7v0dyfo3/
This is (not exactly, without styling) what i'm trying to do for a listing.
It's all good but it does not resize properly.
I would like the div episode-box to expand its height for smartphone screens, so the text can be shown vertically, below the image.
It's not very correctly coded, but can you tell me what are my mistakes for the bad resizing ?
<article class="full-width">
<div class="post-box">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="guide-art-container">
<div class="episode-content">
<div class="saga">
<div class="row">
<div class="col-md-12">
<div class="episode-box">
<div class="episode-img">
<img class="thumbnail-ep" src="http://image.noelshack.com/fichiers/2015/35/1440684992-img.jpg"/>
</div>
<span class="episode-nb"> <p>001</p></span>
<div class="episode-single- content">
<div class="episode-single-title">
<h5><b>Lorem Ipsum Title</b></h5>
</div>
<div class="episode-single- desc">
<p><b>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b>
<br> Sed interdum luctus erat, in Sed interdum luctus erat, in</p>
<hr2>
<span class="cast"><p> <b>Scénario:</b> Sed interdum · <b>Art:</b> Sed interdum · <br>
<b>Animation:</b> Sed interdum · <b>Réalisation:</b> Sed interdum</p></span>
</div>
</div>
</div>
<div class="episode-box">
<div class="episode-img">
<img class="thumbnail-ep" src="http://image.noelshack.com/fichiers/2015/35/1440684992-img.jpg"/>
</div>
<span class="episode-nb"><p>001</p></span>
<div class="episode-single-content">
<div class="episode-single-title">
<h5><b>Lorem Ipsum Title</b></h5>
</div>
<div class="episode-single-desc">
<p><b>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b>
<br> Sed interdum luctus erat, in Sed interdum luctus erat, in</p>
<hr2>
<span class="cast"><p> <b>Scénario:</b> Sed interdum · <b>Art:</b> Sed interdum · <br>
<b>Animation:</b> Sed interdum · <b>Réalisation:</b> Sed interdum</p></span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div><!--.post-box-->
</article>
You need to use media queries
Something like this: (Minimize your browser to see the effect)
.full-width {
margin: 0 0 30px;
padding: 0;
}
.container {
max-width: 1170px;
width: 100%;
}
.row {
margin-right: -15px;
margin-left: -15px;
}
#media (min-width: 1200px)
.col-md-12 {
width: 100%;
}
.guide-art-container {
padding: 25px;
}
.saga-title {
margin-top: 15px;
}
.episode-box {
width: auto;
background-color: #F9F9F9;
margin-top: 7px;
box-shadow: inset 0px 100px 150px -150px rgba(204,204,204,1);
height: 150px;
border: 1px solid #E8E8E8;
position: relative;
}
.episode-img {
float: left;
}
.episode-box img {
float: left;
margin-right: 10px;
padding: 5px;
}
span.episode-nb {
position: absolute;
bottom: 2px;
left: 5px;
background-color: #FC8A19;
max-width: 100px;
width: 100%;
opacity: 0.8;
text-align: center;
color: #fff;
font-weight: bold;
font-size: 15pt;
}
.episode-single-content {
padding: 10px 10px 10px 0px;
max-height: 150px;
}
.episode-single-desc {
max-height: 150px;
font-size: 9pt;
padding-right: 4px;
padding-left: 5px;
padding-top: 5px;
}
span.cast {
font-size: 7.4pt !important;
font-family: 'Roboto', Arial, Tahoma, Sans-serif;
line-height: 19px;
}
.thumbnail-ep {
float: left;
margin-right: 10px;
position: relative;
max-width: 260px;
width: 100%;
padding: 2px;
}
span.episode-nb {
position: absolute;
bottom: 2px;
left: 5px;
background-color: #FC8A19;
max-width: 100px;
width: 100%;
opacity: 0.8;
text-align: center;
color: #fff;
font-weight: bold;
font-size: 15pt;
}
.episode-single-title h5 {
margin-top: 2px !important;
}
#media only screen and (max-width : 480px) {
.episode-img {
float:none;
position:relative;
}
.episode-box img {
float:none;
}
.thumbnail-ep {
float:none;
}
.episode-box {
height:auto;
}
}
<article class="full-width">
<div class="post-box">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="guide-art-container">
<div class="episode-content">
<div class="saga">
<div class="row">
<div class="col-md-12">
<div class="episode-box">
<div class="episode-img">
<img class="thumbnail-ep" src="http://image.noelshack.com/fichiers/2015/35/1440684992-img.jpg"/>
<span class="episode-nb"><p>001</p></span>
</div>
<div class="episode-single-content">
<div class="episode-single-title">
<h5><b>Lorem Ipsum Title</b></h5>
</div>
<div class="episode-single-desc">
<p><b>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b>
<br> Sed interdum luctus erat, in Sed interdum luctus erat, in</p>
<hr2>
<span class="cast"><p><b>Scénario:</b> Sed interdum · <b>Art:</b> Sed interdum · <br>
<b>Animation:</b> Sed interdum · <b>Réalisation:</b> Sed interdum</p></span>
</div>
</div>
</div>
<div class="episode-box">
<div class="episode-img">
<img class="thumbnail-ep" src="http://image.noelshack.com/fichiers/2015/35/1440684992-img.jpg"/>
<span class="episode-nb"><p>001</p></span>
</div>
<div class="episode-single-content">
<div class="episode-single-title">
<h5><b>Lorem Ipsum Title</b></h5>
</div>
<div class="episode-single-desc">
<p><b>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</b>
<br> Sed interdum luctus erat, in Sed interdum luctus erat, in</p>
<hr2>
<span class="cast"><p><b>Scénario:</b> Sed interdum · <b>Art:</b> Sed interdum · <br>
<b>Animation:</b> Sed interdum · <b>Réalisation:</b> Sed interdum</p></span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div><!--.post-box-->
</article>
JS Fiddle
You need media query.
Suppose we have .high-height-in-xs-device
#media screen and (max-width:767px) {
.high-height-in-xs-device {
height: 800px;
}
}
The above CSS will only work in screen with width narrower than 767px, which is a bootstrap standard for xs screen widths.