Content not aligning to the center - html

Im trying to get my "Jumbotron" centered at the top and beneath it have my picture to the left and carousel on the right.
Why does all my content float to the left? Im trying to get everything centered but cant quite make it work.
Im using Bootstrap 5, with flexbox
https://codepen.io/spacemonki87/pen/VwbvogM
HTML:
<section>
<div class="hero">
<div class="row" style="max-width: 1220px;">
<div class="content text-center">
<div class="value-prop text-center">
<h1 class="display-4">Hello, world!</h1>
<p class="lead">This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.</p>
<hr class="my-4">
<p>It uses utility classes for typography and spacing to space content out within the larger container.</p>
<a class="btn btn-success btn-lg" href="#" role="button">Learn more</a>
</div>
<div class="hero-row d-flex">
<div class="hero-img-container d-flex text-center align-items-center" style="margin: 0 auto; width: 84%;">
<img style="max-width: 100%; height: auto;" src="../img/hp_hero_note#2x__en.png" height="800" />
</div>
<div class="carousel-container d-flex align-items-center" style="width: 16%; min-width: 240px;">
<div class="hero-carousel-texts slick-initialized slick-slider slick-dotted">
<div aria-live="polite" class="slick-list draggable">
<div class="slick-track">
<div class="hero-carousel-text slick-slide slick-cloned">
<div class="heading">
<p class="p-title hero-carousel-text-heading">FIND THINGS FAST</p>
</div>
<div class="description">
<p class="p-small">Get what you need, when you need it. Search gives you results as you type.</p>
</div>
</div>
<div class="hero-carousel-text slick-slide slick-cloned">
<div class="heading">
<p class="p-title hero-carousel-text-heading">FIND THINGS FAST</p>
</div>
<div class="description">
<p class="p-small">Get what you need, when you need it. Search gives you results as you type.</p>
</div>
</div>
<div class="hero-carousel-text slick-slide slick-cloned">
<div class="heading">
<p class="p-title hero-carousel-text-heading">FIND THINGS FAST</p>
</div>
<div class="description">
<p class="p-small">Get what you need, when you need it. Search gives you results as you type.</p>
</div>
</div>
<div class="hero-carousel-text slick-slide slick-cloned">
<div class="heading">
<p class="p-title hero-carousel-text-heading">FIND THINGS FAST</p>
</div>
<div class="description">
<p class="p-small">Get what you need, when you need it. Search gives you results as you type.</p>
</div>
</div>
<div class="hero-carousel-text slick-slide slick-cloned">
<div class="heading">
<p class="p-title hero-carousel-text-heading">FIND THINGS FAST</p>
</div>
<div class="description">
<p class="p-small">Get what you need, when you need it. Search gives you results as you type.</p>
</div>
</div>
<div class="hero-carousel-text slick-slide slick-cloned">
<div class="heading">
<p class="p-title hero-carousel-text-heading">FIND THINGS FAST</p>
</div>
<div class="description">
<p class="p-small">Get what you need, when you need it. Search gives you results as you type.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
Any tips on mastering layouts is greatly appreciated

You could just add mx-auto class to first child of div.hero. This will set margin-left and margin-right to auto, centering the contents of the page.
<section>
<div class="hero">
<div class="row mx-auto" style="max-width: 1220px;">
...

Try to add this style into .hero
display: flex;
justify-content: center;

Related

Extra Space in Bootstrap

I am writing in HTML, using Bootstrap 5. I am trying to make a simple row of cards, however there is a lot of empty padding/space. How do I remove this?
Extra Space between cards
Here is my code:
Code\
<div class="row">
<div class="col">
<div onclick="locations(2)" id="location-2" class="w-75 custom-card">
<div class="card-body">
<h5>
<div class="row">
<div class="col">
<img style="border-radius: 5px;" src="https://flagcdn.com/fi.svg" width=40 height=30>
</div>
<div class="col">
<span class="fs-5" style="margin-left:-30px;line-height:-20px;">Helsinki,</span><br><span style="margin-left:-30px;line-height:-20px;" class="fw-normal fs-6">Finland</span>
</div>
</div>
</h5>
</div>
</div>
</div>
<div class="col">
<div onclick="locations(2)" id="location-2" class="w-75 custom-card">
<div class="card-body">
<h5>
<div class="row">
<div class="col">
<img style="border-radius: 5px;" src="https://flagcdn.com/fi.svg" width=40 height=30>
</div>
<div class="col">
<span class="fs-5" style="margin-left:-30px;line-height:-20px;">Helsinki,</span><br><span style="margin-left:-30px;line-height:-20px;" class="fw-normal fs-6">Finland</span>
</div>
</div>
</h5>
</div>
</div>
</div>
</div>
I tried using g-0 in the row, however it did not change at all.

How do I centralize a card in a bootstrap column?

This is html:
<div class="service">
<img src="img/indoor.svg">
<p class="services">indoor</p>
<button class="button">подробнее</button>
</div>
</div>
<div class="col-xxl-4">
<div class="service">
<img src="img/indoor.svg">
<p class="services">BTL</p>
<button class="button">подробнее</button>
</div>
</div>
<div class="col-xxl-4">
<div class="service">
<img src="img/indoor.svg">
<p class="services">на ТВ</p>
<button class="button">подробнее</button>
</div>
</div>
</div>
All my cards are shifted to the left. How can I center them? Offer any options. Thanks for the help.
You might wanna take a look at the Bootstrap Grid system and how it works. If you're indeed using Bootstrap 4 the col-xxl-* won't work, this only exists in Bootstrap 5. Bootstrap 4 only goes up to col-xl.
If you want to center the cards then include this class justify-content-center in the row div. Example is in the following:
<div class="container">
<div class="row justify-content-center">
<div class="col-xxl-4">
<div class="service">
<img src="" class="">
<p class="services">на ТВ</p>
<button class="button">подробнее</button>
</div>
</div>
<div class="col-xxl-4">
<div class="service">
<img src="" class="">
<p class="services">на ТВ</p>
<button class="button">подробнее</button>
</div>
</div>
</div>
</div>

Split a div inside bootstrap vertically

I'm struggling with a rather simple task but the lack of CSS experience is getting the better of me:
<div class="row">
<div class="col-lg-3">
<div class="ibox-content m-b-sm border-bottom">
<div class="ibox-title">
<span class="label label-info pull-right">Offline</span>
<h5>Equipment Pass</h5>
</div>
<div class="ibox-content">
<h1 class="no-margins">#Model.AirportPassEquipmentOffline.TransactionCount</h1>
<small># of Transactions</small>
</div>
</div>
</div>
<div class="col-lg-3">
<div class="ibox-content m-b-sm border-bottom">
<div class="ibox-title">
<span class="label label-success pull-right">Online</span>
<h5>Equipment Pass</h5>
</div>
<div class="ibox-content">
<h1 class="no-margins">#Model.AirportPassEquipmentOnline.TransactionCount</h1>
<small># of Transactions</small>
</div>
</div>
</div>
<div class="col-lg-3">
<div class="ibox-content m-b-sm border-bottom">
<div class="ibox-title">
<span class="label label-info pull-right">Offline</span>
<h5>Visitor Pass</h5>
</div>
<div class="ibox-content">
<h1 class="no-margins">#Model.AirportPassVisitorOffline.TransactionCount</h1>
<small># of Transactions</small>
</div>
</div>
</div>
<div class="col-lg-3">
<div class="ibox-content m-b-sm border-bottom">
<div class="ibox-title">
<span class="label label-success pull-right">Online</span>
<h5>Visitor Pass</h5>
</div>
<div class="ibox-content">
<h1 class="no-margins">#Model.AirportPassVisitorOnline.TransactionCount</h1>
<small># of Transactions</small>
</div>
</div>
</div>
</div>
Above is a row on my view. There are many like it:
I want to split the smallest div to show a second Heading1. Here is base HTML:
<div class="ibox-content">
<h1 class="no-margins">#Model.AirportPassEquipmentOffline.TransactionCount</h1>
<small># of Transactions</small>
<h1 class="no-margins">#Model.AirportPassEquipmentOffline.Income</h1>
<small>Income generated</small>
</div>
Target:
I need to show more information and I see that the div card is empty on the right side. I want to split this div into two. Experimenting with bootstrap classes, the layout breaks.
Afer a bit of trial and error, i realized that the small grid class was the issue. I switched to class-md and got the desired result. So this:
<div class="ibox-content">
<h1 class="no-margins">#Model.AirportPassEquipmentOffline.TransactionCount</h1>
<small># of Transactions</small>
<h1 class="no-margins">#Model.AirportPassEquipmentOffline.Income</h1>
<small>Income generated</small>
</div>
Became this:
<div class="ibox-content">
<div class="row">
<div class="col-md-6">
<h1 class="no-margins">#Model.AirportPassEquipmentOnline.TransactionCount.ToString("N0")</h1>
<small># of Transactions</small>
</div>
<div class="col-md-6">
<h1 class="no-margins">AED #Model.AirportPassEquipmentOnline.Income.ToString("N2")</h1>
<small>Revenue generated</small>
</div>
</div>
</div>

Div's are overlapping each other vertically (Bootstrap)

I have three different divs that should be displaying one after the other, but they just jump right up to each other on the webpage. Here is the code for all of them:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="top-section">
<center>
<div class="container" style="margin-top:150px;">
<div class="row">
<div class="top-title">
<h1>Introducing 10/40 Academy.</h1>
<h3>An affordable entrepreneurship course that can double as high school credit.</h3>
<img src="/Man_iPhone_Desk.jpg" style="height:300px;margin:30px;border-radius:4px;" class="raised hidden-xs" /><br>
Watch Video <span class="glyphicon glyphicon-play-circle"></span>
<h3 class="hidden-sm hidden-xs" style="letter-spacing:2px;margin-top:0px;">SCROLL DOWN</h3>
<h1 class="hidden-sm hidden-xs" style="font-weight:100;font-size:30px;"><span class="glyphicon glyphicon-chevron-down"></span></h1>
</div>
</div>
</div>
</center>
</div>
<div class="begin-tour">
<div class="container">
<div class="row">
<div class="col-md-6" style="margin-top:50px;">
<h2>Interested in small business?</h2>
<h2>We're here to help.</h2>
<p>
Paragraph
</p>
</div>
<div class="col-md-6">
<center>
<img width="70%" src="/MacImageBase.png" />
</center>
</div>
</div>
</div>
</div>
<div class="qualif">
<div class="container">
<div class="row">
<div class="col-md-6">
<h2>Header here</h2>
<h2>Header</h2>
<p>
some text
</p>
</div>
<div class="col-md-6"></div>
</div>
</div>
</div>
The best way to explain what happens is through a photo.
I've added the 3 divs into the bootstrap container, took out center(it is not used anymore or supported by HTML5), put each div as a 12 column row(col-md-12 class) so they show up one after the other like you wanted:
<div class="container">
<div class="row">
<div class="top-section col-md-12">
<div class="container" style="margin-top:150px;">
<div class="row">
<div class="top-title">
<h1>Introducing 10/40 Academy.</h1>
<h3>An affordable entrepreneurship course that can double as high school credit.</h3>
<img src="/Man_iPhone_Desk.jpg" style="height:300px;margin:30px;border-radius:4px;" class="raised hidden-xs" /><br>
Watch Video <span class="glyphicon glyphicon-play-circle"></span>
<h3 class="hidden-sm hidden-xs" style="letter-spacing:2px;margin-top:0px;">SCROLL DOWN</h3>
<h1 class="hidden-sm hidden-xs" style="font-weight:100;font-size:30px;"><span class="glyphicon glyphicon-chevron-down"></span></h1>
</div>
</div>
</div>
</div>
<div class="begin-tour col-md-12">
<div class="container">
<div class="row">
<div class="col-md-6" style="margin-top:50px;">
<h2>Interested in small business?</h2>
<h2>We're here to help.</h2>
<p>
Paragraph
</p>
</div>
<div class="col-md-6">
<center>
<img width="70%" src="/MacImageBase.png" />
</center>
</div>
</div>
</div>
</div>
<div class="qualif col-md-12">
<div class="container">
<div class="row">
<div class="col-md-6">
<h2>Header here</h2>
<h2>Header</h2>
<p>some text</p>
</div>
<div class="col-md-6"></div>
</div>
</div>
</div>
</div>
</div>
Here is the plunker so you can see it.
Please let me know if this helps. I didn't see your image until now so I hope it helps.

Bootstrap css center nested div

I'm havent been front end coding for quite a while, havent been coding at all for quite a while. Now i'm trying some things again and i'm kinda stuck at something and hoping you folks could help me out :)
I've got a bootstrap row with nested divs. I want to center align the nested div's but can't seem to figure out how. Is there anyone able to push me in the right direction? My code is as follows:
<!--Features block Start-->
<div class="row">
<div id="features" class="col-sm-12">
<div class="row">
<div class="col-sm-3 features-content"><img class="center" src="img/icons/ssd.png" alt="ssd"><h3 class="center">SSD.</h3><p class="center">Placeholder text.</p></div>
<div class="col-sm-3 features-content"><img class="center" src="img/icons/network.png" alt="network"><h3 class="center">Network.</h3><p class="center">Place holder text</p></div>
<div class="col-sm-3 features-content"><img class="center" src="img/icons/database.png" alt="database"><h3 class="center">Database.</h3><p class="center">Placeholder text.</p></div>
</div>
<div class="row features-content">
<div class="col-sm-3 features-content"><img class="center" src="img/icons/opensource.png" alt="ssd"><h3 class="center">We <span class="glyphicon glyphicon-heart heart-color"></span> Open Source.</h3><p class="center">Placeholder text.</p></div>
<div class="col-sm-3 features-content"><img class="center" src="img/icons/cpanel.png" alt="network"><h3 class="center">CPanel.</h3><p class="center">Placeholder text.</p></div>
<div class="col-sm-3 features-content"><img class="center" src="img/icons/support.png" alt="database"><h3 class="center">24/7 Support.</h3><p class="center">Placeholder text.</p></div>
</div>
</div>
</div>
<!--Features block Stop-->
with the following CSS
#features{
background-color:#e1dbc5;
position: relative;
}
#features-content{
margin: 0 auto;
}
which results in: http://i.imgur.com/AhJKjkE.png
Anyone able to shed some light on this for me? If there is anything unclear or you need more information from me please ask!
Kind regards,
Arjen.
#features-content{
margin: 0 auto;
text-align:center;
}
#features{
background-color:#e1dbc5;
position: relative;
text-align:center;
}
text-align center on both ID's
actually it is much easier if you use the default grid for more nesting to get your design right
<div class="row">
<div id="features" class="col-sm-12" style="text-align:center;">
<div class="row">
<div class="col-sm-4 features-content">
<img class="center" src="img/icons/ssd.png" alt="ssd">
<h3 class="center">SSD.</h3>
<p class="center">Placeholder text.</p>
</div>
<div class="col-sm-4 features-content">
<img class="center" src="img/icons/network.png" alt="network">
<h3 class="center">Network.</h3>
<p class="center">Place holder text</p>
</div>
<div class="col-sm-4 features-content">
<img class="center" src="img/icons/database.png" alt="database">
<h3 class="center">Database.</h3>
<p class="center">Placeholder text.</p>
</div>
</div>
<div class="row features-content" style="text-align:center;">
<div class="col-sm-4 features-content">
<img class="center" src="img/icons/opensource.png" alt="ssd">
<h3 class="center">We <span class="glyphicon glyphicon-heart heart-color"></span> Open Source.</h3>
<p class="center">Placeholder text.</p>
</div>
<div class="col-sm-4 features-content">
<img class="center" src="img/icons/cpanel.png" alt="network">
<h3 class="center">CPanel.</h3>
<p class="center">Placeholder text.</p>
</div>
<div class="col-sm-4 features-content">
<img class="center" src="img/icons/support.png" alt="database">
<h3 class="center">24/7 Support.</h3>
<p class="center">Placeholder text.</p>
</div>
</div>
</div>
</div>
check this