Fixed position element within a bootstrap 4 column - html

I am trying to have a bar sit at the bottom of the users screen, but only within a column. I can use position:fixed; bottom:0; if I want the element to stretch across the entire screen, but I can't figure out how to make the bar stay within the column. See picture for example
In the above picture, I want the Like, Comment, Share box to always be at the bottom of the users screen, but stay within the column it's in.
I'm using bootstrap 4, and you can see the website here: https://www.arelplane.com/#arelenglish
EDIT:
HTML of page
<div class='container-fluid user-profile'>
<div class='row'>
<div class='col-md-3 col-12 d-none d-md-block remove-lr-padding' id='sticky-sidebar'>
<div class='row mt-5 mb-5 align-center'>
<div class="col-12">
Some text
</div>
</div>
<div class="row social-module">
<div class="col-4">
Like
</div>
<div class="col-4">
Comment
</div>
<div class="col-4">
Share
</div>
</div>
</div>
<div class='col-md-9 col-12 remove-lr-padding' id='user-map'>
<div class="user-map" id="cesiumContainer"></div>
</div>
</div>
</div>
CSS
.social-module {
background-color: blue;
// position:fixed;
bottom:0;
width: 100%;
margin-left: 0;
margin-right: 0;
}
Edit 2:
Fiddle: https://jsfiddle.net/arel/9t3tnhzt/3/

This is how you make the bar stay at the bottom of the column:
<div class="d-flex align-items-end">...</div>
Alternatively, add the align-items-end class to that column.
No need for custom css in Bootstrap 4.
Here's a working example:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
<div class="container-fluid user-profile">
<div class="row">
<div class="col-4 remove-lr-padding" id="sticky-sidebar">
<div class="row text-center">
<div class="col-12 bg-warning" style="min-height: 100vh;">
<p>Feature requests? Questions?</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate temporibus assumenda molestias laborum ipsam quisquam, nisi, aspernatur quia, ratione ipsum illo cum exercitationem nostrum dolor corrupti ducimus sunt provident harum. Eum, ullam id! Adipisci perspiciatis reiciendis minus quisquam culpa nobis voluptatem suscipit iusto dolores hic ab impedit incidunt rem labore praesentium, sed itaque voluptates distinctio vero temporibus quia atque magni ratione. Ratione, sit maiores asperiores architecto deserunt ducimus dignissimos? Error doloremque reiciendis repellendus esse dolor at expedita non. Ipsum maxime optio quasi, ratione pariatur excepturi aperiam. Dolores nisi magni est suscipit placeat nobis quaerat fugit culpa laboriosam, quam autem aut nesciunt fuga reiciendis dolor omnis doloremque ab corporis dicta adipisci eos amet ipsa. Qui beatae possimus pariatur nemo ducimus autem, architecto officia libero nisi quo, a earum repellendus explicabo cumque quidem consequatur sapiente ipsam molestias molestiae, nostrum sed nesciunt neque. Ex accusantium inventore quam! Commodi tempora eligendi possimus nam ut similique quidem, rem enim, quo quisquam autem accusantium! Suscipit error a quidem adipisci. Repellat maxime nesciunt id quasi deleniti, consectetur, est eius commodi doloremque odit, fugiat! Consequatur modi distinctio reiciendis natus et quibusdam eum doloribus temporibus delectus obcaecati laboriosam earum, ad eveniet! Ea, necessitatibus perferendis, nostrum aperiam saepe voluptates reiciendis odit, quis porro ipsa omnis ab iste doloribus, cupiditate nobis eos enim cum molestias facilis laudantium ex. Hic at impedit in alias.</p>
</div>
<div class="row social-module position-sticky fixed-bottom m-0 w-100 py-2 bg-primary">
<div class="col-12 col-md-4">
Like
</div>
<div class="col-12 col-md-4">
Cmnt
</div>
<div class="col-12 col-md-4">
Share
</div>
</div>
</div>
</div>
<div class="col-8 remove-lr-padding" id="user-map">
hello
</div>
</div>
</div>
I just added the h-100 class to the row and then added the position-sticky class to the other row.
Oh, and I ripped out your margins. :-)

Related

Bootstrap 5. how to remove page scrolling

I want to make sure that only the card-body block scrolls. Now the page scrolls a bit when the card-body block overflows (there are 2 scroll bars). The lorem text was inserted for an overflow example.
The result should be as in the picture. The crossed-out scroll bar should be removed, and the ticked one should remain
enter image description here
html, body {
height: 100%;
}
.ts_panel {
height: 100%;
border-right: 2px solid #646464;
background: rgb(44,44,44);
}
.ts_usernameInp {
width: 40%;
margin: 0 auto;
}
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<title></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<link rel="stylesheet" href="index.css">
</head>
<body>
<div class="container-fluid d-flex h-100 flex-column">
<header class="row justify-content-center align-items-center bg-dark text-white text-center py-2">
<span>Ссылка для подключения к чату: 127.0.0.1:8000/chat/?chat_id=tZGuDGqdHa0e3IAfTRY7</span>
</header>
<div class="row h-100">
<div class="col-2 ts_panel">
<h1 class="text-center text-white">Чат</h1>
</div>
<div class="col-10 p-0 h-100">
<div class="card w-100 h-100">
<form class="h-100" action="" method="post">
<div class="d-flex flex-column h-100">
<div class="card-header flex-fill text-center">
<input type="text" class="form-control ts_usernameInp" placeholder="Username" aria-label="Username" aria-describedby="basic-addon1">
</div>
<div class="card-body flex-fill overflow-auto">
Obcaecati dolor quam voluptate praesentium quaerat et maxime provident tempora alias suscipit facere est, laborum ad aperiam quas animi corporis neque delectus nostrum hic nisi! Omnis, ea atque.Lorem ipsum dolor sit amet consectetur adipisicing elit. Nostrum, nam expedita fugiat aperiam, ad corporis voluptatem laudantium assumenda deleniti, cum quasi voluptatibus. Beatae cum ratione debitis expedita ducimus veritatis suscipit, quod aperiam magni nihil ab voluptas dolorum eaque? At necessitatibus tempora enim, quisquam possimus ipsa provident fugiat quaerat nobis. Delectus aliquam porro beatae rerum eligendi distinctio ab voluptatem vero dignissimos neque in itaque maiores nostrum aspernatur excepturi, minima totam magni nesciunt blanditiis, accusamus hic consequatur! Sint eveniet error optio corrupti dicta dolores reprehenderit quas molestiae, saepe exercitationem culpa commodi doloremque cum rem quod sit accusamus enim alias. Quod dolore veritatis a magni, dolor cum quo libero enim reprehenderit, aut ex, nobis et possimus reiciendis dolorem. Quae, fugit quasi! Voluptatum saepe numquam quam, nobis sint ipsam maiores sunt? Eius ab quasi aut ullam aliquam architecto, placeat optio dolorum cumque odio dolorem recusandae explicabo cum. Consequuntur odit a illum tenetur illo exercitationem architecto soluta corrupti, temporibus voluptate consequatur maxime impedit praesentium quisquam eius dolorem. Aspernatur, neque tenetur corporis inventore quisquam aliquid perferendis eaque doloremque. Laborum laboriosam magnam alias nam blanditiis temporibus omnis dolor, quae sint modi officiis earum possimus voluptatibus. Molestiae nihil debitis repellat provident officiis sint quaerat aliquam eos eum accusantium aliquid, quam exercitationem nesciunt dolorum, sunt maxime. Consequatur consectetur sunt explicabo aperiam ipsam eaque labore obcaecati cupiditate. A ut culpa similique ipsam illo ducimus placeat id eligendi officia nulla beatae quasi sunt cum rem, consequatur nisi nam ab? Impedit cum assumenda reprehenderit consectetur?
</div>
<div class="flex-fill card-footer">
<div class="input-group">
<input type="text" class="form-control" placeholder="Введите сообщение" aria-label="Сообщение" aria-describedby="basic-addon2">
<div class="input-group-append">
<button class="btn btn-primary" type="button">Отправить</button>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
Okay, you must use this for block scrolling bars overflow-y: hidden; overflow-x: hidden; but you must make Mobile optimalization use https://www.w3schools.com/cssref/css3_pr_mediaquery.asp and add the new css and done fixed.
html, body {
height: 100%;
overflow-y: hidden;
overflow-x: hidden;
}
if you need still help, make comment i help you.

How to place an img behind a card and make it responsive

I would like to put an image behind a card and make it responsive
Quite useless to share my code because i really don't know where to go with this problem.
I already tried to put the img in a :after or :before but i could't manage to make it not break the display:flex of the card container, i tried to put it in the card using z-index but it creates a blank space before the text.
So i tried to schematize what i would like to do, thanks a lot! :)
Ugly drawing of what i want :D
you can use position relative to the parent and position absolute to the image which you want to place behind and adjust the top and bottom values
Codepen
.main-row>div{
background-color: #ffd5ff;
border-radius: 24px;
}
.main-row p::first-letter {
color: red;
font-size: xx-large;
}
.main-row .smily {
position:absolute;
top:-35px;
left:-35px;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css">
<div class="container">
<div class="row main-row d-flex text-justify mt-5 d-flex justify-content-between position-relative">
<img src="https://pngimg.com/uploads/smiley/smiley_PNG155.png" style="height:60px; width:auto;" class="smily">
<div class="col-lg-3 para1 p-4 shadow mb-4">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere, rem ratione deserunt necessitatibus ducimus excepturi quisquam hic, eum esse dignissimos laboriosam assumenda sapiente voluptas fugiat nulla inventore repellat consequuntur quasi?
Soluta mollitia voluptatibus molestiae, magnam rerum accusamus veritatis minima totam veniam! Incidunt ratione cupiditate quia aspernatur excepturi sit dolorum, fugit harum officia hic quam beatae itaque pariatur atque! Deserunt, provident.</p></div>
<div class="col-lg-3 para2 p-4 shadow mb-4"><p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere, rem ratione deserunt necessitatibus ducimus excepturi quisquam hic, eum esse dignissimos laboriosam assumenda sapiente voluptas fugiat nulla inventore repellat consequuntur quasi?
Soluta mollitia voluptatibus molestiae, magnam rerum accusamus veritatis minima totam veniam! Incidunt ratione cupiditate quia aspernatur excepturi sit dolorum, fugit harum officia hic quam beatae itaque pariatur atque! Deserunt, provident.</p></div>
<div class="col-lg-3 para3 p-4 shadow mb-4"><p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Facere, rem ratione deserunt necessitatibus ducimus excepturi quisquam hic, eum esse dignissimos laboriosam assumenda sapiente voluptas fugiat nulla inventore repellat consequuntur quasi?
Soluta mollitia voluptatibus molestiae, magnam rerum accusamus veritatis minima totam veniam! Incidunt ratione cupiditate quia aspernatur excepturi sit dolorum, fugit harum officia hic quam beatae itaque pariatur atque! Deserunt, provident.</p></div>
</div>
<div class="row">
<a class="mx-auto mt-4" href="https://www.neramclasses.com"><strong>show some love by adding this link to your website as a credit</strong></a></div></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
'

Bootstrap 4.2.1, text appears outside the div

the text inside div is going outside, I don't know how to fix it. I've tried the way of putting columns in the order like shown in my code from here:
How can I get a Bootstrap column to span multiple rows?
An Image used as a template
How the page looks like
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>About us</title>
<!-- versioning can often help (href="css/style.css?ver=2.0") -->
<!-- BOOTSTRAP 4 -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<style>
body {
background-color: #696969;
margin-top: 100px;
}
.well {
background-color: #deedee;
margin: 3px;
}
</style>
</head>
<body>
<div class="container-fluid text-center">
<div class="row">
<div class="col-md-7">
<div class="row">
<div class="col-md-12">
<div class="well">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptate, molestiae saepe! Facilis quidem dolorem temporibus mollitia doloremque, possimus voluptas error aperiam iusto repellendus numquam, laudantium nemo a, debitis nam eveniet repellat rem voluptates culpa iure nisi quae asperiores nulla molestiae consequatur. Facilis quos soluta necessitatibus, excepturi libero. Veritatis impedit expedita architecto assumenda quo cum earum reprehenderit ad reiciendis, explicabo consequatur, iste facilis vel esse nesciunt nihil animi minima eum accusantium eveniet nam. Dolor quas voluptates, officiis numquam corporis quos. Doloribus nisi maiores placeat quas minima, autem numquam natus totam quidem nostrum, quos vel illo magnam blanditiis quam eligendi sed voluptates.</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="well">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptate, molestiae saepe! Facilis quidem dolorem temporibus mollitia doloremque, possimus voluptas error aperiam iusto repellendus numquam, laudantium nemo a, debitis nam eveniet repellat rem voluptates culpa iure nisi quae asperiores nulla molestiae consequatur. Facilis quos soluta necessitatibus, excepturi libero. Veritatis impedit expedita architecto assumenda quo cum earum reprehenderit ad reiciendis, explicabo consequatur, iste facilis vel esse nesciunt nihil animi minima eum accusantium eveniet nam. Dolor quas voluptates, officiis numquam corporis quos. Doloribus nisi maiores placeat quas minima, autem numquam natus totam quidem nostrum, quos vel illo magnam blanditiis quam eligendi sed voluptates.</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="well">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptate, molestiae saepe! Facilis quidem dolorem temporibus mollitia doloremque, possimus voluptas error aperiam iusto repellendus numquam, laudantium nemo a, debitis nam eveniet repellat rem voluptates culpa iure nisi quae asperiores nulla molestiae consequatur. Facilis quos soluta necessitatibus, excepturi libero. Veritatis impedit expedita architecto assumenda quo cum earum reprehenderit ad reiciendis, explicabo consequatur, iste facilis vel esse nesciunt nihil animi minima eum accusantium eveniet nam. Dolor quas voluptates, officiis numquam corporis quos. Doloribus nisi maiores placeat quas minima, autem numquam natus totam quidem nostrum, quos vel illo magnam blanditiis quam eligendi sed voluptates.</div>
</div>
</div>
</div>
<div class="col-md-5">
<div class="well m-0">
<div class="row">
<div class="col-md-7">
Jan Kustra
<br>
<br>
<br>
<br>
<br>
<br>
</div>
<div class="col-md-5">
<img src="img/300.png" alt="my face" width="50%" class="float-right">
</div>
</div>
<div class="row">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Magni similique, suscipit laudantium, error explicabo repellat aperiam, ullam ab non exercitationem vitae, totam quidem eaque labore. Totam neque eaque architecto facilis, unde laudantium quas. Id vel, unde error, fugiat vero ipsa dicta doloribus mollitia ea et eaque incidunt esse. Aliquid ipsa perspiciatis reiciendis, eligendi dolorum architecto, voluptatum, consectetur similique ex quo ad nam, itaque officiis id porro ducimus doloremque reprehenderit. Inventore vel rem voluptatem ullam ab itaque harum rerum, ut hic modi facilis minus quibusdam, veniam quam ipsum. At maiores tenetur, natus illo repudiandae velit, similique harum accusantium voluptatum, quia quas!</p>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
You're missing the column surrounding the text block.
Yours:
<div class="row">
<p>Lorem ipsum...</p>
</div>
Correct:
<div class="row">
<div class="col-md-12">
<p>Lorem ipsum...</p>
</div>
</div>

resizing bootstrap accordion

I have a section of a site that uses an h2, followed by an accordion. I am trying to have the accordion and h2 pull-left, however the accordion is the wrong size, unless it is expanded in which it enlarges itself. I have a sidebar column set up as so: <div class="col-md-3">
thus I want the h2, and accordion to be to the right of that but take up the full screen on the right of that. My accordion and h2 is set up as follows:
<div class="col-md-9 pull-right">
<div class="panel-body">
<h2 class="page-header col-md-9 pull-left">Action Strategies: What We Can Do Now</h2>
<div class="panel-group col-md-9 pull-left" id="accordion">
with each panel like so:
<!-- /.panel -->
<div class="panel panel-default">
<div class="panel-heading teachers">
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">Teachers and Support Staff</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse">
<div class="panel-body">
<!-- content -->
</div>
</div>
</div>
As I understood your problem, pull-right is causing it. Please see the attached snippets if this is was you need.
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div class="col-md-3">
<h3>Sidebar</h3>
<div>Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro esse officiis ipsa, placeat praesentium laborum rerum iste aspernatur omnis ratione exercitationem eligendi. Soluta id ipsa nisi ex! Cumque, voluptatum laudantium hic, ea cum, vitae aperiam expedita delectus autem iusto nam voluptatem dolorum fugiat? Laudantium minima, eos eius harum voluptatem error!</div>
</div>
<div class="col-md-9">
<div class="row">
<div class="col-md-12">
<h2 class="page-header col-md-9 pull-left">Action Strategies: What We Can Do Now</h2>
</div>
</div>
<div class="panel-group " id="accordion">
<div class="panel panel-default">
<div class="panel-heading teachers">
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapse1">Teachers and Support Staff 1</a>
</h4>
</div>
<div id="collapse1" class="panel-collapse collapse">
<div class="panel-body">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quos architecto atque nemo nisi explicabo dolor. Magni perferendis modi vero pariatur officia consectetur, vitae id. Aspernatur officia nam ipsum ea dolorum laborum error maxime quidem provident rerum facere eum, unde? Ducimus quos provident adipisci, odit porro itaque eligendi beatae obcaecati tenetur minima officiis libero, nesciunt quidem autem ex cupiditate ratione veniam repellat est consequuntur quibusdam aut suscipit at. Provident quod, dolor quae incidunt vitae non neque, molestiae minus veritatis deleniti eligendi laboriosam blanditiis nostrum eum quia qui voluptas nemo expedita aliquam dolorum nihil. Quas dolor neque voluptatibus quos optio reprehenderit, impedit?
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading teachers">
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapse2">Teachers and Support Staff 2</a>
</h4>
</div>
<div id="collapse2" class="panel-collapse collapse">
<div class="panel-body">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Qui ex laboriosam libero suscipit natus, voluptatibus, perferendis eos omnis impedit minima fugit a ipsum ipsa rem numquam placeat provident magnam asperiores mollitia vero magni laudantium pariatur. Obcaecati error rem dolor itaque quidem eligendi, voluptas vero voluptatem, labore adipisci perferendis quia velit reiciendis illo libero optio. Aliquam autem labore voluptas veritatis praesentium, in a tempore accusamus error ad laboriosam omnis consequuntur, pariatur dolor voluptates dolores vel. Repellat animi tenetur expedita nobis est a natus hic adipisci eligendi aliquam quo minus, dolorum nihil provident odit delectus suscipit omnis nostrum quod magni, voluptatum. Laboriosam!
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading teachers">
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapse3">Teachers and Support Staff 3</a>
</h4>
</div>
<div id="collapse3" class="panel-collapse collapse">
<div class="panel-body">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Obcaecati, voluptatem, itaque cumque dolorem dicta eveniet porro voluptatibus unde ad nostrum est accusantium veniam, iste natus incidunt quis consectetur quod placeat deserunt corporis veritatis quidem! Eaque facilis quasi, rem reiciendis! Voluptatibus quasi, necessitatibus repellendus impedit, fugit minima vero eius, perferendis dignissimos vel nulla velit! Error commodi veniam maxime reprehenderit aut sint voluptatem id culpa autem corrupti optio expedita blanditiis odit dolorem obcaecati vitae delectus ea necessitatibus beatae laboriosam aliquid, eos eveniet nobis quos quidem? Quia itaque dicta quasi perferendis earum, fuga illo aperiam architecto nisi iure suscipit omnis esse facilis, saepe.
</div>
</div>
</div>
</div>
</div>
</div>
</div>

Avoid whitespaces with float left

I would like to know how I can avoid the big whitespace using float: left, all the block does not have the same height
here's a demo
<div class="container">
<div class="block">
<div class="content">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laudantium, molestias vel quia ratione a nostrum quae provident facere perspiciatis commodi!</div>
</div>
<div class="block">
<div class="content">Est, eaque, enim? Illo, incidunt, molestias aut expedita aspernatur consectetur quos sit accusantium hic mollitia beatae numquam itaque excepturi eaque.</div>
</div>
<div class="block">
<div class="content">Nihil, quibusdam animi voluptatum modi pariatur aliquam adipisci nostrum placeat eos atque maxime odit optio molestias nisi dignissimos. Cum, vel?</div>
</div>
<div class="block">
<div class="content">Tempore, adipisci voluptatibus iure temporibus aut hic deleniti inventore accusantium excepturi vel et omnis veritatis itaque nesciunt odit ut nemo?</div>
</div>
<div class="block">
<div class="content">Voluptas, dignissimos, reiciendis, rem quasi neque quia molestiae in consequatur animi at et qui sint nihil ipsum corrupti totam repudiandae?</div>
</div>
<div class="block">
<div class="content">Tempora, velit, incidunt a est sed nostrum optio suscipit in sint eveniet architecto pariatur culpa asperiores minus praesentium perspiciatis dignissimos.</div>
</div>
<div class="block" style="height:200px"><!-- this height is for example, the height can be higher or lower -->
<div class="content">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam, enim, quidem laudantium quo iusto deleniti sed assumenda placeat dolorem est?</div>
</div>
<div class="block">
<div class="content">Earum, ut, laudantium, eaque, quaerat architecto officiis magni iusto eum nesciunt asperiores illum sit. Et officiis modi tempore mollitia sunt.</div>
</div>
<div class="block">
<div class="content">Nobis, placeat, tenetur tempore facere reiciendis illo reprehenderit sunt a ratione hic deleniti quaerat fuga ex minus eum culpa laborum.</div>
</div>
<div class="block">
<div class="content">Qui, nostrum, ab, totam, molestias quaerat expedita saepe odit accusamus reiciendis rerum officia provident iusto voluptate quis quos sit nisi.</div>
</div>
<div class="block">
<div class="content">Eum, dolorem, qui, autem dolorum et molestiae asperiores rerum eius minus iste quaerat labore distinctio vel cum quis atque consequatur.</div>
</div>
<div class="block">
<div class="content">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iure est magni necessitatibus consequatur deleniti aut veniam repellat quis similique ab.</div>
</div>
<div class="clear"></div>
</div>
Style.css
body {color:white;}
.clear{clear: both;}
.block {float:left;width: 50%;height:100px;}
.content {margin: 10px; padding: 10px; background-color: #000;}
Using regular css you can't really avoid the whitespace underneath each of your elements.
The only way to do it with css would be to have all of your content arranged in columns, not all actually floated left.
Most people get around this problem by using a plugin such as http://masonry.desandro.com/ which uses jQuery/JavaScript to make it work.
Hope that helps.