Stop fixed block on last element - html

I have the following snippet (open snippet as full page) :
#container_1{
margin-top: 50px;
margin-bottom: 150px;
}
.block1{
background: green;
margin-bottom: 15px;
color: #FFFFFF;
}
#moving_block{
z-index: 0;
background-color: purple;
color: #FFFFFF;
}
#footer{
background-color: gray;
height: 5000px;
color: #FFFFFF;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div id="container_1" class="container">
<div class="col-md-5 col-md-offset-1">
<div class="row block1">
<div class="col-md-8">
<p>TEXT</p>
</div>
</div>
<div class="row block1">
<div class="col-md-8">
<p>TEXT</p>
</div>
</div>
<div class="row block1">
<div class="col-md-8">
<p>TEXT</p>
</div>
</div>
<div class="row block1">
<div class="col-md-8">
<p>TEXT</p>
</div>
</div>
<div class="row block1">
<div class="col-md-8">
<p>TEXT</p>
</div>
</div>
</div>
<div class="col-md-4">
<div id="moving_block" class="col-md-3 affix">
<div class="row">
<p>TEXT</p>
</div>
</div>
</div>
</div>
<section id="footer">
MY FOOTER
</section>
I would like to stop the purple block when he encounter the last green block.

This can be done using position:sticky.
I consider bootstrap V4 for this since there is builtin function for sticky. I also simplified the code to keep only the relevant one for the demo:
#container_1 {
margin-top: 50px;
margin-bottom: 150px;
}
.block1 {
background: green;
color: #FFFFFF;
}
.block1:not(:last-child) {
margin-bottom: 15px;
}
#moving_block {
background-color: purple;
color: #FFFFFF;
}
#footer {
background-color: gray;
height: 5000px;
color: #FFFFFF;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet">
<div id="container_1" class="container">
<div class="row">
<div class="col-5 col-offset-1">
<div class="row block1">
<p>TEXT</p>
</div>
<div class="row block1">
<p>TEXT</p>
</div>
<div class="row block1">
<p>TEXT</p>
</div>
<div class="row block1">
<p>TEXT</p>
</div>
<div class="row block1">
<p>TEXT</p>
</div>
</div>
<div class="col-6">
<div id="moving_block" class="overflow-auto position-sticky sticky-top">
<p>TEXT</p>
</div>
</div>
</div>
</div>
<section id="footer">
MY FOOTER
</section>

Related

Bootstrap 4 Trying to get this Grid Format

Trying to Get this Grid format
Hello, I am currently new to using bootstrap 4 and am trying to get the format above.
This is what I am currently trying so far....
<div class="container">
<div class="row">
<div class="col-md-4" >1</div>
<div class="col-md-8">2</div>
<div class="col-md-8 ">3</div>
</div>
</div>
Here you go!
.content {
min-height: 100px;
background: #ccc;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="col-4">
<div class="row h-100">
<div class="col-12 h-100">
<div class="content h-100">1</div>
</div>
</div>
</div>
<div class="col-8">
<div class="row">
<div class="col-12 mb-3 pl-0">
<div class="content">2</div>
</div>
<div class="col-12 pl-0">
<div class="content">3</div>
</div>
</div>
</div>
</div>
</div>
.one, .two, .three{
border: solid 2px gray;
min-height: 150px;
font-weight: bold;
}
.one{
background: lightblue;
}
.two{
background: lightgreen;
}
.three{
background: pink;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-sm-5 one">1</div>
<div class="col-sm-7">
<div class="row">
<div class="col-sm-8 two">2</div>
</div>
<div class="row">
<div class="col-sm-8 three">3</div>
</div>
</div>
</div>
</div>

Scroll two bootstrap cols independently

I have two bootstrap 4 cards on a page that contain content of differing length.
I want to set the initial height of the cards to extend to the bottom of the page, and overflow-y: scroll on each card independently.
See below for my code (same thing as a fiddle).
Currently, scrolling on one card causes the other to scroll too. How can I get them to scroll independently? The answer to a similar question suggests setting the height of the parent div, which I am currently doing (#message-row{height: 100%}), so I can't see what I'm doing wrong.
I would also like to make sure that the footer for the right had card is always at the bottom of the visible card (i.e. so that you don't have to scroll to the bottom of the card to see it.
.message-card {
font-weight: 400;
height: 100%;
overflow-y: scroll;
}
.inbox-card {
font-weight: 300;
height: 100%;
overflow-y: scroll;
}
#message-row {
height: 500px;
color: #232323;
overflow-y: scroll;
text-align: left;
}
#message-row .card {
border-radius: 5px;
}
#message-row input {
width: 70%;
color: #0e5286 !important;
}
#message-row input.form-control {
height: unset !important;
background: #f5f9fc;
}
#message-row .inbox-row {
margin-right: 0;
margin-left: 0;
padding-bottom: 1em;
}
#message-row .inbox-row:hover {
cursor: pointer;
background-color: #f5f9fc;
}
.speech-bubble {
position: relative;
max-width: 100%;
min-height: 40px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
padding: 10px;
margin-bottom: 0.5em;
}
.speech-bubble.them {
background: rgba(155, 194, 214, 0.6);
}
.speech-bubble.me {
background: rgba(156, 199, 160, 0.6);
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
<div class="container d-flex h-100 flex-column">
<div id="message-row" class="row mb-4">
<div class="col-lg-5 pb-md-4 pb-lg-0">
<div class="card">
<div class="searchBar">
<input id="inbox-search" class="form-control mx-auto mt-2" type="text" placeholder="Search..." />
</div>
<div id="inbox" class="card-body">
<div class="row inbox-row">
<div class='col-12'>
<p>Some content 1 </p>
</div>
</div>
<div class="row inbox-row">
<div class='col-12'>
<p>Some more content</p>
</div>
</div>
<div class="row inbox-row">
<div class='col-12'>
<p>Some content again </p>
</div>
</div>
<div class="row inbox-row">
<div class='col-12'>
<p>Some content asdaa</p>
</div>
</div>
<div class="row inbox-row">
<div class='col-12'>
<p>Some asdacc </p>
</div>
</div>
<div class="row inbox-row">
<div class='col-12'>
<p>Some contention</p>
</div>
</div>
<div class="row inbox-row">
<div class='col-12'>
<p>Some contention</p>
</div>
</div>
<div class="row inbox-row">
<div class='col-12'>
<p>Some contention</p>
</div>
</div>
<div class="row inbox-row">
<div class='col-12'>
<p>Some contention</p>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-7">
<div class="card message-card">
<div id="conversation" class="card-body">
<div class='row'>
<div class='col-8 float-right'>
<div class='speech-bubble me'>A message</div>
</div>
</div>
<div class='row'>
<div class='col-8 float-right'>
<div class='speech-bubble me'>Another message</div>
</div>
</div>
<div class='row'>
<div class='col-8 float-right'>
<div class='speech-bubble them'>A reply</div>
</div>
</div>
</div>
<div id="new-message" class="card-footer">
<form id="reply-form" method="POST">
<input type="hidden" name="sender" value="<abcd">
<div class="form-info-text form-group mb-0">
<div class="row">
<div class="col-11">
<textarea class="form-control autoExpand" rows="1" name="message"></textarea>
</div>
<div class="col-1 send-col">
<button type="submit" disabled><i id="sendMessage" class="far fa-paper-plane"></i></button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class='container-fluid'>
<div class='row'>
<div class='col-12'>
<h1>
Some other container that expands full width...
</h1>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
Remove height and overflow from class message-row also reduce height in message-card and include a class inbox in first card
.inbox {
font-weight: 300;
height: 80%;
overflow-y: scroll;
}
.message-card {
font-weight: 400;
height: 80%;
overflow-y: scroll;
}
.inbox {
font-weight: 300;
height: 80%;
overflow-y: scroll;
}
#message-row {
color: #232323;
text-align: left;
}
#message-row .card {
border-radius: 5px;
}
#message-row input {
width: 70%;
color: #0e5286 !important;
}
#message-row input.form-control {
height: unset !important;
background: #f5f9fc;
}
#message-row .inbox-row {
margin-right: 0;
margin-left: 0;
padding-bottom: 1em;
}
#message-row .inbox-row:hover {
cursor: pointer;
background-color: #f5f9fc;
}
.speech-bubble {
position: relative;
max-width: 100%;
min-height: 40px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
padding: 10px;
margin-bottom: 0.5em;
}
.speech-bubble.them {
background: rgba(155, 194, 214, 0.6);
}
.speech-bubble.me {
background: rgba(156, 199, 160, 0.6);
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
<div class="container d-flex h-100 flex-column">
<div id="message-row" class="row mb-4">
<div class="col-lg-5 pb-md-4 pb-lg-0">
<div class="card inbox">
<div class="searchBar">
<input id="inbox-search" class="form-control mx-auto mt-2" type="text" placeholder="Search..." />
</div>
<div id="inbox" class="card-body ">
<div class="row inbox-row">
<div class='col-12'>
<p>Some content 1 </p>
</div>
</div>
<div class="row inbox-row">
<div class='col-12'>
<p>Some more content</p>
</div>
</div>
<div class="row inbox-row">
<div class='col-12'>
<p>Some content again </p>
</div>
</div>
<div class="row inbox-row">
<div class='col-12'>
<p>Some content asdaa</p>
</div>
</div>
<div class="row inbox-row">
<div class='col-12'>
<p>Some asdacc </p>
</div>
</div>
<div class="row inbox-row">
<div class='col-12'>
<p>Some contention</p>
</div>
</div>
<div class="row inbox-row">
<div class='col-12'>
<p>Some contention</p>
</div>
</div>
<div class="row inbox-row">
<div class='col-12'>
<p>Some contention</p>
</div>
</div>
<div class="row inbox-row">
<div class='col-12'>
<p>Some contention</p>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-7">
<div class="card message-card">
<div id="conversation" class="card-body">
<div class='row'>
<div class='col-8 float-right'>
<div class='speech-bubble me'>A message</div>
</div>
</div>
<div class='row'>
<div class='col-8 float-right'>
<div class='speech-bubble me'>Another message</div>
</div>
</div>
<div class='row'>
<div class='col-8 float-right'>
<div class='speech-bubble them'>A reply</div>
</div>
</div>
</div>
<div id="new-message" class="card-footer">
<form id="reply-form" method="POST">
<input type="hidden" name="sender" value="<abcd">
<div class="form-info-text form-group mb-0">
<div class="row">
<div class="col-11">
<textarea class="form-control autoExpand" rows="1" name="message"></textarea>
</div>
<div class="col-1 send-col">
<button type="submit" disabled><i id="sendMessage" class="far fa-paper-plane"></i></button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class='container-fluid'>
<div class='row'>
<div class='col-12'>
<h1>
Some other container that expands full width...
</h1>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
Actually after banging my head against the desk for several hours I realised that the solution was simple: It's the cols that need overflow-y: scroll, not the cards. Thus adding class scroll-col to each column fixes the problem:
.scroll-col{
height: 100%;
overflow-y: scroll;
}
(See fiddle)

How can I reduce the horizontal space between col-md-4 divs?

HTML
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="content">1x1</div>
</div>
<div class="col-md-4">
<div class="content">1x2</div>
</div>
<div class="col-md-4">
<div class="content">1x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="content">2x1</div>
</div>
<div class="col-md-4">
<div class="content">2x2</div>
</div>
<div class="col-md-4">
<div class="content">2x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="content">3x1</div>
</div>
<div class="col-md-4">
<div class="content">3x2</div>
</div>
<div class="col-md-4">
<div class="content">3x3</div>
</div>
</div>
</div>
CSS
.container {
text-align: center;
display: flex;
flex-direction: column;
}
.content {
background-color: #1A1919;
color: white;
height: 400px;
width: 300px;
}
.row{
padding: 5px;
}
I have managed to make vertical spaces between the columns by adding padding to the rows. But now the horizontal spaces between the contents are ways too much. How can I configure the spacing between them?
That large horizontal space is because of the fixed width of the content class if you remove that, you'll see it grow.
You can set the width of the content in % or add a margin to the content class.
.container {
text-align: center;
}
.content {
background-color: #1A1919;
color: white;
height: 400px;
}
.row{
padding:15px;
}
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="col-md-4 col4">
<div class="content">1x1</div>
</div>
<div class="col-md-4 col4">
<div class="content">1x2</div>
</div>
<div class="col-md-4 col4">
<div class="content">1x3</div>
</div>
</div>
<div class="row ">
<div class="col-md-4 col4">
<div class="content">2x1</div>
</div>
<div class="col-md-4 col4">
<div class="content">2x2</div>
</div>
<div class="col-md-4 col4">
<div class="content">2x3</div>
</div>
</div>
<div class="row col4 col4">
<div class="col-md-4 col4">
<div class="content">3x1</div>
</div>
<div class="col-md-4 col4">
<div class="content">3x2</div>
</div>
<div class="col-md-4">
<div class="content">3x3</div>
</div>
</div>
</div>
CSS Grid to achieve that layout you desire:
.grid-container {
display: grid;
grid-template-columns: auto auto auto;
grid-gap: 5px;
position:absolute;
left:50%;
transform:translateX(-50%);
width:80%;
}
.item {
background-color: gray;
text-align: center;
font-size: 30px;
min-height:100px;
max-width: 350px;
}
<div class="grid-container">
<div class="item">1x1</div>
<div class="item">1x2</div>
<div class="item">1x3</div>
<div class="item">2x1</div>
<div class="item">2x2</div>
<div class="item">2x3</div>
<div class="item">3x1</div>
<div class="item">3x2</div>
<div class="item">3x3</div>
</div>
Using flexbox:
.flex-container {
display: flex;
/*Generates a flexbox layout with default flex direction as row */
width: 100%;
/* Not really required */
align-items: center;
/*Aligns contents vertically */
justify-content: center;
/*Aligns contents horizontally */
text-align: center;
/*Aligns further text in the center */
}
.item {
background-color: gray;
text-align: center;
font-size: 30px;
min-height: 400px;
width: 300px;
margin: 5px;
}
<div class="flex-container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
</div>
<div class="flex-container">
<div class="item">4</div>
<div class="item">5</div>
<div class="item">6</div>
</div>
<div class="flex-container">
<div class="item">7</div>
<div class="item">8</div>
<div class="item">9</div>
</div>
Use float:left; with class content as below:
.container {
text-align: center;
display: flex;
flex-direction: column;
}
.content {
float: left;
background-color: #1A1919;
color: white;
height: 400px;
width: 300px;
}
.row{
padding: 5px;
}
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="content">1x1</div>
</div>
<div class="col-md-4">
<div class="content">1x2</div>
</div>
<div class="col-md-4">
<div class="content">1x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="content">2x1</div>
</div>
<div class="col-md-4">
<div class="content">2x2</div>
</div>
<div class="col-md-4">
<div class="content">2x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="content">3x1</div>
</div>
<div class="col-md-4">
<div class="content">3x2</div>
</div>
<div class="col-md-4">
<div class="content">3x3</div>
</div>
</div>
</div>
If I'm reading your request correctly, you are just asking how to make it look like the boxes are in the center of the page, and they are evenly spaced. see if this is what you're looking for:
.container {
text-align: center;
display: flex;
flex-direction: column;
}
.content {
background-color: #1A1919;
color: white;
height: 400px;
width: 300px;
}
.col-md-4 {
margin: 5px -10px 0px -4px;;
}
play with the numbers until you get the desired location.
Though I would strongly suggest that you add your own class in addition to col-md-4 to the boxes, which will prevent this new setting to col-md-4 from affecting any future use of this bootstrap class.
in other words . . .
CSS:
.container {
text-align: center;
display: flex;
flex-direction: column;
}
.content {
background-color: #1A1919;
color: white;
height: 400px;
width: 300px;
}
.box-move {
margin: 5px -10px 0px -4px;;
}
and HTML:
<div class="container">
<div class="row">
<div class="col-md-4 box-move">
<div class="content">1x1</div>
</div>
<div class="col-md-4 box-move">
<div class="content">1x2</div>
</div>
<div class="col-md-4 box-move">
<div class="content">1x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4 box-move">
<div class="content">2x1</div>
</div>
<div class="col-md-4 box-move">
<div class="content">2x2</div>
</div>
<div class="col-md-4 box-move">
<div class="content">2x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4 box-move">
<div class="content">3x1</div>
</div>
<div class="col-md-4 box-move">
<div class="content">3x2</div>
</div>
<div class="col-md-4 box-move">
<div class="content">3x3</div>
</div>
</div>
</div>
You can remove a lot of the stuff there and simplify it to make it responsive width a set margin:
.contents {
background-color: black;
color: white;
height: 500px;
margin: 20px 0px;
}
<div class="container-fluid text-center">
<div class="row">
<div class="col-md-4">
<div class="contents">1x1</div>
</div>
<div class="col-md-4">
<div class="contents">1x2</div>
</div>
<div class="col-md-4">
<div class="contents">1x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="contents">2x1</div>
</div>
<div class="col-md-4">
<div class="contents">2x2</div>
</div>
<div class="col-md-4">
<div class="contents">2x3</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="contents">3x1</div>
</div>
<div class="col-md-4">
<div class="contents">3x2</div>
</div>
<div class="col-md-4">
<div class="contents">3x3</div>
</div>
</div>
</div>
</div>

Separate bootstrap classes with my own?

I use bootstrap. Do I need separate rows with my own classes? Because if I don't I can't set the background of the section for example. Which piece of code is better?
<div class="container">
<nav class="row"></nav>
<section class="row">
<div class="col-sm-3">
some text
</div>
</section>
</div>
 
<div class="container">
<div class="row">
<nav></nav>
</div>
<div class="row">
<section>
<div class="col-sm-3">
some text
</div>
</section>
</div>
</div>
You can use both and change background of section as you prefer. Just add your own class and set css.
nav{
height:30px !important;
width:100%;
display:block;
background-color: red;
}
.containercolor{
background-color: black;
margin:0px;
}
.row{
margin: 0px !important;
}
.sectionrow{
height: 200px;
}
.colcolor{
background-color: green;
height:100%;
}
.sectionrow{
background-color: blue;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<nav>
</nav>
<div class="container-flex containercolor">
<div class="row sectionrow">
<div class="col-xs-6">
</div>
<div class="col-xs-6 colcolor">
</div>
</div>
</div>
<div class="container-flex ">
<div class="row containercolor">
<nav></nav>
</div>
<div class="row">
<section class="sectionrow">
<div class="col-sm-3">
some text
</div>
</section>
</div>
</div>

How to create a template with CSS?

Im trying to create a template like this one:
But im not sure if I have to created with css, bootstrap or both.
This is what I have
HTML:
<div class="square">
<div class="col-md-12">
<div class="col-md-2">
<img src="../Images/logo.png" class="text-left" style="width:120px;"/>
</div>
<div class="col-md-5 text-center">
<h4>Alert PLC</h4>
</div>
<div class="col-md-5 text-center">
<h4>No. Alert: 44445543</h4>
</div>
<div class="col-md-10">
<hr class="line" />
</div>
</div>
CSS
body {
background-color: #aeaeae;
}
.square {
padding-top: 10px;
padding-left: 10px;
padding-right: 10px;
padding-bottom: 10px;
}
.line {
height: 4px;
color: #000000;
border-radius: 2px;
background-color: #000000;
}
Here is JSfiddle demo
Hope it will help you.I made several changes in html.
HTML:
<body>
<div class="square">
<div class="row">
<div class="col-md-4">
<img src="https://image.freepik.com/free-vector/retro-retro-hipster-bicycle-design_23-2147491723.jpg" class="pull-left" style="width:120px;"/>
</div>
<div class="col-md-4 text-center">
<h4>Alert PLC</h4>
</div>
<hr class="line" />
<div class="col-md-4 text-center">
<h4>No. Alert: 44445543</h4>
</div>
</div>
</div>
</body>