CSS does not work and DOM structure from HTML - html

.empty-space{
width: 30%;
float: left;
}
.download-information{
width: 70%;
float: left;
}
.download-thumbnail img {
height: 30px;
width: 30px;
float: left;
}
.download-profile{
float: left;
}
<div class="download-content">
<div class="download-information">
<div class="empty-space"></div>
<div class="information">
<div class="download-thumbnail"><img src="https://media.istockphoto.com/photos/cloud-computing-picture-id1087885966" alt="Sample image"></div>
<div class="download-profile">
<b><div class="img-title">Demo title</div></b>
<div class="img-description">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et</div>
</div>
</div>
</div>
<div class="download-link-content">
<div class="download-link-content">
<div class="download-icon"><i class="fas fa-download"></i></div>
<div class="link-to-download">Download</div>
<div class="download-link-information">
<span>(
<span class="download-filesize">3,2 MB,</span>
<span class="download-filestype">PDF</span>
)
</span>
</div>
</div>
<div class="empty-space"></div>
</div>
</div>
I have the following mockup which I am now trying to model.
I have thought of the following HTML framework and associated CSS:
<div class="download-content">
<div class="download-information">
<div class="empty-space"></div>
<div class="information">
<div class="download-thumbnail"></div>
<div class="download-profile">
<b><div class="img-title"></div></b>
<div class="img-description"></div>
</div>
</div>
</div>
<div class="download-link-content">
<div class="download-link-content">
<div class="download-icon"><i class="fas fa-download"></i></div>
<div class="link-to-download"></div>
<div class="download-link-information">
<span>(
<span class="download-filesize">,</span>
<span class="download-filestype"></span>
)
</span>
</div>
</div>
<div class="empty-space"></div>
</div>
</div>
.empty-space{
width: 30%;
float: left;
}
.download-information{
width: 70%;
float: left;
}
.download-thumbnail {
height: 30px;
width: 30px;
float: left;
}
.download-profile{
float: left;
}
Unfortunately it doesn't work and frontend is not my strength at all and unfortunately I don't know anyone who can help me here how to do it. Can someone here help me how it should look or how I would have to style the CSS?
Add 1:
Is my idea of the HTML DOM wrong or is it possible to implement this so that the image can also be displayed correctly
Add 2:
Add snippet to my post. I don't get it. It's only a privat project but don't get the frontend styling.

I would not use all these floats, but to stay as close to what you did as possible, here's what you can do:
Move .download-profile into the .information div.
Create an additional wrapper div around .thumbnail and the div which follows after it (which contains the image title and description). (To only have two child elements in .download-profile which will be placed beside each other)
Apply display: flex to .download-profile
.empty-space {
width: 30%;
float: left;
}
.download-information {
width: 70%;
float: left;
}
.download-thumbnail img {
height: 30px;
width: 30px;
float: left;
margin: 0 10px 6px 0;
}
.download-profile {
float: left;
display: flex;
}
<div class="download-content">
<div class="download-information">
<div class="empty-space"></div>
<div class="information">
<div class="download-profile">
<div class="download-thumbnail"><img src="https://media.istockphoto.com/photos/cloud-computing-picture-id1087885966" alt="Sample image"></div>
<div>
<b><div class="img-title">Demo title</div></b>
<div class="img-description">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et</div>
</div>
</div>
</div>
</div>
<div class="download-link-content">
<div class="download-link-content">
<div class="download-icon"><i class="fas fa-download"></i></div>
<div class="link-to-download">Download</div>
<div class="download-link-information">
<span>(
<span class="download-filesize">3,2 MB,</span>
<span class="download-filestype">PDF</span> )
</span>
</div>
</div>
<div class="empty-space"></div>
</div>
</div>

It looks as though the CSS grid property will help here as it will work out how much space to leave between items tso you don't need to worry about floats or having empty space divs.
Here's a snippet to get you started. Obviously you'll want to look at the exact proportions you want for each part. You may also want to have a media query so that narrow devices use the full width of the screen for example.
You could also review your HTML structure as, with thinking of it in grid terms, it might be possible to simplify it.
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
width: 100vw;
height: 100vh;
}
.download-content {
display: grid;
grid-template-columns: 2fr 1fr;
width: 70%;
margin: 0 auto 0 auto;
}
.information{
width: 70%;
display: grid;
grid-template-columns: 1fr 6fr;
}
.download-thumbnail img {
width: 100%;
height: auto;
}
.download-link-info div {
display: inline-block;
}
</style>
</head>
<body>
<div class="download-content">
<div class="download-information">
<div class="information">
<div class="download-thumbnail"><img src="https://media.istockphoto.com/photos/cloud-computing-picture-id1087885966" alt="Sample image"></div>
<div class="download-profile">
<b><div class="img-title">Demo title</div></b>
<div class="img-description">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et</div>
</div>
</div>
</div>
<div class="download-link-content">
<div class="download-link-info">
<div class="download-icon"><i class="fa fa-download" aria-hidden="true"></i></div>
<div class="link-to-download">Download</div>
<div class="download-link-information">
<span>(
<span class="download-filesize">3,2 MB,</span>
<span class="download-filestype">PDF</span>
)
</span>
</div>
</div>
</div>
</div>
</body>

Related

How to do word-break in a non-rectangle div?

My Problem
I'm working on website which has comments that look like Facebook's comments. The text and user's name in the comments can be edited dynamically.
I can't figure out how to break a long text correctly after the user's name.
What I've Tried
Using 'word-break: break-all' on my wrapper div.
Examples
What i'm trying to achieve:
What i get:
My Code (Simplified)
html:
<div class="comment_wrapper">
<div class="name"></div>
<div class="text_wrapper">
<div class="space_holder"></div>
<div class="text"></div>
</div>
</div>
relevant css:
.text_wrapper{
word-break: break-all;
}
.space_holder{
width: /*Equals to name's width + 10px. Changes dynamically with
javascript when the name is edited. */
}
Help much appreciated!
EDITED: SOLUTION
This worked for me:
html:
<div class="comment_wrapper">
<div class="name"></div>
<div class="text_wrapper">
<div class="space_holder"></div>
<div class="text"></div>
</div>
</div>
relevant css:
.text_wrapper{
word-break: break-all;
}
.space_holder{
width: /*Equals to name's width + 10px. Changes dynamically with
javascript when the name is edited. */
float: left;
}
.text{
display: inline;
}
If you add a float: left; to .space_holder you can wrap the floated name.
.text_wrapper {
word-break: break-all;
}
.space_holder {
width: 75px;
float: left;
}
<div class="comment_wrapper">
<div class="name"></div>
<div class="text_wrapper">
<div class="space_holder">John Doe</div>
<div class="text">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.</div>
</div>
</div>

Having trouble achieving specific CSS Grid layout

I am trying to create a shopping cart page. This is my goal:
I though about using Flexbox since this is one dimensional layout, but wanted to get some practice with CSS Grid. I think CSS Grid is a good solution because I can see 6 unequal sized columns. I think I'm close, but my spacing is way off. This is what I have so far:
.shopping-cart .product-row {
display: grid;
grid-template-columns: repeat(6, auto);
border-bottom: 1px solid #eee;
}
.shopping-cart .product-row .product-image img {
width: 100px;
}
.shopping-cart .product-row .product-details {
display: inline-block;
grid-column-start: 2;
grid-column-end: 3;
}
.shopping-cart .product-row .product-details .product-description {
display: inline-block;
margin: 5px 20px 0px 0;
width: 50%;
line-height: 1.4em;
}
.shopping-cart .product-row .product-quantity input {
width: 40px;
}
<div class="shopping-cart">
<div class="product-row">
<div class="product-image">
<img src="https://www.drivencoffee.com/wp-content/uploads/2016/03/Scandinavian-Blend-coffee.jpg" />
</div>
<div class="product-details">
<div class="product-title">Coffee</div>
<div class="product-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim </div>
</div>
<div class="product-price">12.99</div>
<div class="product-quantity">
<input type="number" value="2" min="1" />
</div>
<div clas="product-removal">
<button class="remove-product">
Remove
</button>
</div>
<div class="product-total-price">
25.98
</div>
</div>
</div>
Here's a code pen of the same code
I think my problem is with grid-template-columns: repeat(6, auto). It's creating 6 columns and each column is only as big as the content inside of it. I'm just not sure how to achieve for accurate positioning.
Thank you for any help.
As per my comments to this question, you can try creating an 8-column layout using grid-template-columns: repeat(8, 1fr) and use grid-column: span 3 for product-details element - see demo below:
.shopping-cart .product-row {
display: grid;
grid-template-columns: repeat(8, 1fr); /* CHANGED */
border-bottom: 1px solid #eee;
}
.shopping-cart .product-row .product-image img {
width: 100px;
}
.shopping-cart .product-row .product-details {
display: inline-block;
grid-column: span 3; /* CHANGED */
}
.shopping-cart .product-row .product-details .product-description {
display: inline-block;
margin: 5px 20px 0px 0;
width: 50%;
line-height: 1.4em;
}
.shopping-cart .product-row .product-quantity input {
width: 40px;
}
<div class="shopping-cart">
<div class="product-row">
<div class="product-image">
<img src="https://www.drivencoffee.com/wp-content/uploads/2016/03/Scandinavian-Blend-coffee.jpg" />
</div>
<div class="product-details">
<div class="product-title">Coffee</div>
<div class="product-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim </div>
</div>
<div class="product-price">12.99</div>
<div class="product-quantity">
<input type="number" value="2" min="1" />
</div>
<div clas="product-removal">
<button class="remove-product">
Remove
</button>
</div>
<div class="product-total-price">
25.98
</div>
</div>
</div>
Why not try to use the old methods:
Want to use the grid ?
.row {
display: block;
}
img, input {
max-width: 100%;
}
.img {
width: 64px;
}
.amount {
width: 56px;
}
.details {
width: calc(100% - 64px * 5);
}
.col {
display: inline-block;
vertical-align: middle;
border: 1px solid red;
}
<div class="shopping-cart">
<div class="row">
<div class="col img"><img src="https://www.drivencoffee.com/wp-content/uploads/2016/03/Scandinavian-Blend-coffee.jpg"/></div>
<div class="col details">
<div class="product-title">Coffee</div>
<div class="product-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim </div>
</div>
<div class="col">12.99</div>
<div class="col amount"><input type="number" value="2" min="1" /></div>
<div class="col"><button class="remove-product"> Remove </button></div>
<div class="col">25.98</div>
</div>
</div>
I have used bootstrap to handle the issue.
Bootstrap is very response across various display sizes, take a look over the code below
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<div class="row">
<div class="col-xs-2">
<img style="width: 100%;" src="https://www.drivencoffee.com/wp-content/uploads/2016/03/Scandinavian-Blend-coffee.jpg" />
</div>
<div class="col-xs-2">
<div class="product-title">Coffee</div>
<div class="product-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim </div>
</div>
<div class="col-xs-2">12.99</div>
<div class="col-xs-2">
<input type="number" value="2" min="1" />
</div>
<div class="col-xs-2">
<button class="remove-product">
Remove
</button>
</div>
<div class="col-xs-2">
25.98
</div>
</div>
I know you are asking about a solution for css grid, but I think your first idea was better. A shopping cart is a LIST of elements from which some have a more or less fixed size and position and another, the description, needs to adapt depending on the width. That for me is a list of flex items with flex-flow: row nowrap adding a flex: auto to the description.
Also, there is no need for a headers row, as concepts are clear if you order them properly: Photo > description > Price x [Quantity] > Total > Actions.
I forked your pen to show you an example: https://codepen.io/jesuke/pen/aMYGdv
However if you think Headers are required, then what you are looking for is a data table with fixed layout I believe. The fixed Layout will give you that accurate positioning you are looking for.
This solution uses grid template column names and assigning them where required. Some of the template settings use minmax() to allow for some flexibility. Of course, you should adjust these to fit your specifications.
The product-details section is set to flex with a column layout.
Included as well is the header portion from OP's image of the desired layout. This is set as a grid as well and the appropriate column names are assigned to the header labels.
Furthermore, some slight enchancements, are a slight indent on product-title (as shown in the supplied image from OP) and also pre-prending a $ to the product-price value.
Benefits to named grid templates is that assignment is made easy as well as setting the grid cell values are easily edited without much thought to which numbered column am I editing, for example.
.shopping-cart,
.product-row > div {
display: flex;
justify-content: center;
}
.shopping-cart {
flex-direction: column;
}
.shopping-cart__header,
.shopping-cart .product-row {
display: grid;
grid-template-columns: [product-image] 6rem [product-details] minmax(11rem, 24rem) [product-price] 5rem [product-quantity] 5rem [product-removal] 6rem [product-total-price] 5rem;
grid-column-gap: 0.5rem;
grid-template-rows: 1fr;
border-bottom: 1px solid #eee;
align-items: center;
}
[class*="shopping-cart__header__label"] {
text-align: center;
}
.shopping-cart__header__label-price {
grid-column-start: product-price;
}
.shopping-cart__header__label-quantity {
grid-column-start: product-quantity;
}
.shopping-cart__header__label-total {
grid-column-start: product-total-price;
}
.shopping-cart .product-row .product-image img {
width: 100%;
}
.shopping-cart .product-row .product-image {
grid-column-start: product-image;
}
.shopping-cart .product-row .product-details {
grid-column-start: product-details;
display: flex;
flex-direction: column;
padding: 0.625rem;
}
.shopping-cart .product-row .product-details .product-title {
padding-left: 0.635rem;
}
.shopping-cart .product-row .product-price {
grid-column-start: product-price;
}
.shopping-cart .product-row .product-quantity {
grid-column-start: product-quantity;
}
.shopping-cart .product-row .product-quantity input {
width: 2.5rem;
}
.shopping-cart .product-row .product-removal {
grid-column-start: product-removal;
}
.shopping-cart .product-row .product-total-price {
grid-column-start: product-total-price;
}
.shopping-cart .product-row .product-total-price:before {
content: '$';
}
<div class="shopping-cart">
<header class="shopping-cart__header">
<span class="shopping-cart__header__label-price">Price</span>
<span class="shopping-cart__header__label-quantity">Quantity</span>
<span class="shopping-cart__header__label-total">Total</span>
</header>
<div class="product-row">
<div class="product-image">
<img src="https://www.drivencoffee.com/wp-content/uploads/2016/03/Scandinavian-Blend-coffee.jpg" />
</div>
<div class="product-details">
<div class="product-title">Coffee</div>
<div class="product-description">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim </div>
</div>
<div class="product-price">12.99</div>
<div class="product-quantity">
<input type="number" value="2" min="1" />
</div>
<div clas="product-removal">
<button class="remove-product">
Remove
</button>
</div>
<div class="product-total-price">
25.98
</div>
</div>
</div>

Unaligned images with text underneath? CSS / HTML

unaligned images and text
I have attempted to input suggestions from previous questions but it just seems I have been able to successfully find the correct way to align these images with their text underneath.
<section id="boxes">
<div class="container">
<div class="box">
<img src="./images/dayporter2.jpeg">
<h3>DAYPORT</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
do eiusmod
tempor incididunt ut labore et dolore magna aliqua.
</p>
</div>
<div class="box">
<img src="./images/floorcare1.jpeg">
<div class="box">
<h3>FLOOR CARE</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
do eiusmod
tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
<div class="box">
<img src="./images/janitor2.jpeg">
</div>
</section>
/* boxes */
#boxes{
margin-top: 20px;
}
#boxes .box{
float: left;
text-align: center;
width: 30%;
padding: 10px;
}
#boxes .box img{
width: 90px;
}`
You seem to have an unnecessary div tag.
remove the div tag after your 'floorcare1.jpeg' img, here:
<img src="./images/floorcare1.jpeg">
<div class="box"> //remove this
<div class="box">
<img src="./images/floorcare1.jpeg">
<div class="box"> <!-- The probleme is here -->
<h3>FLOOR CARE</h3>
Because the .box element which is direct below the image is float left, it will force the image to be float left, because their sibling .box take 30% of the parent and there are remaining 70% width of their .box parent element. You must remove the .box element and every thing will work like you expecting.
Another problem you must close all you open markup
<section>
<div class="container">
<div class="box">
<!-- First box -->
</div>
<div class="box">
<!-- Second box -->
</div>
<div class="box">
<!-- Third box -->
</div>
</div>
</section>

CSS Having border around 2 divs

I'm using TYPO3 with a calendar extension (cal). It creates events and shows them as a list. Currently, it looks like that:
Now I want to have a border around the date, but just as big as the text.
This is the extension's template:
<div class="col-md-3 text-center" style="text-align:center;">
<div class="event-wrapper">
<div class="img-wrapper">
<div class="date-wrapper">
<div class="date" title="###MICROFORMAT_START###" class="dtstart"><span class="borderspan">###STARTDATE###</span></div>
</div>
<div class="image">###IMAGE###</div>
</div>
<div class="text-wrapper">
<div class="time">###STARTTIME######ENDTIME###</div>
<h3><!-- ###EVENT_LINK### start-->###TITLE###<!-- ###EVENT_LINK### end--></h3>
<p>###DESCRIPTION###</p>
</div>
</div>
</div>
Div with class "date" is the relevant part.
This template creates this code:
<div class="col-md-3 text-center" style="text-align:center">
<div class="event-wrapper">
<div class="img-wrapper">
<div class="date-wrapper">
<div class="date" title="20170118T210000" class="dtstart"><span class="borderspan">
<div class="day">18.</div>
<div class="month">Januar</div></span>
</div>
</div>
<div class="image"></div>
</div>
<div class="text-wrapper">
<div class="time">21:00 Uhr - 23:00 Uhr</div>
<h3>Frankfurt/Main</h3>
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takim</p>
</div>
</div>
</div>
I tried to give the class "borderspan" a border, but this didn't worked and looked like this afterwards:
How can I have a border around the date?
You could try using ::before and ::after like so:
.date-wrapper {
max-width: 200px;
background: orange;
text-align: center;
}
.date::before,
.date::after {
content: "";
width: 1px;
height: 25px;
background: black;
display: block;
margin: 0 auto;
}
.date {
margin: 25px 0;
}
<div class="date-wrapper">
<div class="date" title="###MICROFORMAT_START###">
<span class="borderspan">###STARTDATE###</span>
</div>
</div>
Also notice (like #Banzay mentions) don't use class="" twice per element.
Your date is a <div> element which is block element by default. Means it take up whole width available. We need to make it inline-block, so the width will be content related. Plus add some padding to make some space between the text and a border. I set the border width equal to your text-line width and color to match the text color. Take a look:
.date {
display: inline-block;
padding: 7px;
border: 7px solid #ea644f;
}

3 divs horizontally, set last's height to auto

I have 3 divs, each with width:100%, placed under each other.
Here's how it looks:
My code is:
<div class="welcome">
<h1>Welcome</h1>
<small>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.</small>
</div>
<div class="welcome2">
<h1>About</h1>
<small>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.<small>
</div>
<div class="welcome3">
<h1>Why choose us?</h1>
<div class="row">
<div class="col-md-4 why">
<i class="fa fa-reply-all fa-3x why-icon"></i>
<strong>Fast support</strong>
<p>Our moderators will help you with your problem.</p>
</div>
<div class="col-md-4 why">
<i class="fa fa-reply-all fa-3x why-icon"></i>
<strong>Fast support</strong>
<p>Our moderators will help you with your problem.</p>
</div>
<div class="col-md-4 why">
<i class="fa fa-reply-all fa-3x why-icon"></i>
<strong>Fast support</strong>
<p>Our moderators will help you with your problem.</p>
</div>
<div class="col-md-4 why">
<i class="fa fa-reply-all fa-3x why-icon"></i>
<strong>Fast support</strong>
<p>Our moderators will help you with your problem.</p>
</div>
<div class="col-md-4 why">
<i class="fa fa-reply-all fa-3x why-icon"></i>
<strong>Fast support</strong>
<p>Our moderators will help you with your problem.</p>
</div>
<div class="col-md-4 why">
<i class="fa fa-reply-all fa-3x why-icon"></i>
<strong>Fast support</strong>
<p>Our moderators will help you with your problem.</p>
</div>
</div>
</div>
CSS
.welcome
{
text-align: center;
width: 100%;
background-color: #3BA666;
background-image: linear-gradient(60deg, #4DAC71 50%, #3BA666 50%);
padding: 50px;
}
.welcome2
{
text-align: center;
width: 100%;
background-color: #FF61E7;
background-image: linear-gradient(60deg, #FF61E7 50%, #FF61D0 50%);
padding: 50px;
}
.welcome3
{
text-align: center;
width: 100%;
background-color: #32C8DE;
background-image: linear-gradient(60deg, #32D0DE 50%, #32C8DE 50%);
padding: 50px;
}
.why
{
/** text-align: left; **/
padding: 15px;
}
.why-icon
{
color: #0E495C;
display: block;
}
I want it to be like that - first two are normal height, and the last one always fill the empty white space. Is this possible?
Here is the Fiddle: https://jsfiddle.net/21dydo07/1/
Yes, with CSS3.
Give the design's parents (body, html, ...) a height of 100%. Then set some height to .welcome and .welcome2, e.g. 200px each. After that, set .welcome3 to take the rest, like this:
html, body {height: 100%}
.welcome, .welcome2 {height: 200px}
.welcome3 {height: calc(100% - 400px)}
Another solution would be to set specific height for every element (that would also be CSS2 comapatible), but that wouldn't allow you to always fill 100% of the screen height and have the third div with a variable height.
If you need the first solution, but you also need CSS2 compliance (e.g. for IE8), then you might need a javascript fallback, that will set the height to .welcome3 accordingly at pageload, something like this (needs jQuery):
$(document).ready(function() {
$(".welcome3").css("height",$(window).height()-400);
});
If the sentences in the first two blocks can be wrapped to single-line, use this:
You could use calc().
Make sure that the wrapper for these three has a height style.
For .welcome and .welcome2, set padding and line-height either in px or in em. For example, if the calculated height comes out to be 300px use height: calc(100% - 300px) for .welcome3. Note: The spaces around the operator - are important.
You can do this with Flexbox, set min-height: 100vh; on wrap div and flex: 1; on welcome3 so it will always take free space of viewport
html, body {
margin: 0;
padding: 0;
}
.wrap {
display: flex;
min-height: 100vh;
flex-direction: column;
text-align: center;
}
.welcome {
background: #3CA666;
padding: 20px;
}
.welcome2 {
background: #FF61D0;
padding: 20px;
}
.welcome3 {
background: #32C9DE;
flex: 1;
padding: 20px;
}
<div class="wrap">
<div class="welcome">
<h1>Welcome</h1>
<small>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.</small>
</div>
<div class="welcome2">
<h1>About</h1>
<small>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.</small>small>
</div>
<div class="welcome3">
<h1>Welcome 3</h1>
<small>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua</small>
</div>
</div>