So I'm using bootstrap to create an index home page
what I'm trying to do is basically align in the center 2 divs on top of each other :
I have a container-fluid
then a row with 2 cols: in 1 of the cols I have 2 divs that I want to be aligned in the center ( both horizontally and vertically ),
( code is shown below )
here's an illustration :
what I want to do
green is the container-fluid ||
red and blue are the divs I want to be aligned || an orange is a login form I want to add later on
my code goes like this :
<div class="container-fluid mainwrapper p-2">
<div class="row">
<div class="col">
<div>
<img src="pictures/logooo.png" class="my-2" alt="uc2">
</div>
<div>
<a class="rounded shadow-sm bg-white biorHv px-3">Faculté NTIC | Departement de Scolarité</a>
</div>
</div>
<div class="col">
<!-- Login form here -->
</div>
</div>
</div>
here's a real picture of the problem
i want the green logo and the writing with the white background to be aligned in the center of the left column
real problem
what I realy want
Add text-center class to divs you want to align center. Shown in below code
<div class="col">
<div class="text-center">
<img src="pictures/logooo.png" class="my-2" alt="uc2">
</div>
<div class="text-center">
<a class="rounded shadow-sm bg-white biorHv px-3">Faculté NTIC | Departement de Scolarité</a>
</div>
</div>
This will solve your problem..
add these steps:
HTML
<div class="text-center">
<img src="pictures/logooo.png" class="my-2" alt="uc2">
</div>
css
.col {
padding-left:50px;
}
you can just give "col-md-6" to with column and a "text-align:center;" (horizontal align), and "margin:0 auto". Try this.
<div class="container-fluid mainwrapper p-2">
<div class="row">
<div class="col-md-6" style="text-align:center;">
<div style="float: none; margin: 0 auto;">
<div>
<img src="pictures/logooo.png" class="my-2" alt="uc2">
</div>
<div>
<a class="rounded shadow-sm bg-white biorHv px-3">Faculté NTIC | Departement de Scolarité</a>
</div>
<div>
</div>
<div class="col-md-6">
<!-- Login form here -->
</div>
</div>
</div>
Related
I am using this theme: https://themeforest.net/item/memento-multipurpose-funeral-services-html-template/23890802
Can somebody explain me where I start with centering the logo + the menubar?
<section class="page_toplogo ls s-pt-25 s-pb-20 s-py-md-30">
<div class="container">
<div class="row align-items-center">
<div class="col-lg-12">
<div class="d-md-flex justify-content-md-end align-items-md-center">
<div class="mr-auto">
<div class="d-none d-md-flex justify-content-center justify-content-md-start">
<a href="./" class="logo">
<img src="images/logo.png" alt="">
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
thanks in advance
If all you want to do is to center the logo your can remove the mr-auto class from the html or this css
.page_toplogo .mr-auto {
margin-right: 0 !important;
}
If you also want to remove those items to the right of the logo, either remove the html or hide them with display: none and replace justify-content-center with justify-content-start to the logo wrapper.
I am currently using bootstrap 4 for the cards. I would like to add a numbering beside my card. which is show in the image below.
I tried adding padding-top on the span text the same goes with the assigned col of the span text but the card beside it is adjusting as well. Can anyone help me with this one?
I want the numbering to be at the horizontal range of the card either at the top or at the middle, as you can see it's above the card.
<div class="container">
<div class="col-sm-2">
<span style="display:inline-block; padding-top: 15px;" >1</span>
</div>
<div class="col-sm-12">
<div class="card h-100" style="width: 15rem;">
<div>
<a class="fancybox" href="admin/files/Images/flutterfest.png">
<img class="card-img-top" src="admin/files/Images/flutterfest.png">
</a>
</div>
<div class="card-body">
<h5 class="card-title text-center">Library Management System</h5>
<p class="card-text">Date added: <span>May 23, 2021</span></p>
</div>
</div>
</div>
</div>
give column classes as col-sm-2 and col-sm-10. there are 12 columns max you can create in bootstrap. So you have given col-sm-12 to second div thats why it is going to next line
<div class="col-sm-2">
<span style="display:inline-block; padding-top: 15px;" >1</span>
</div>
<div class="col-sm-10">
I'm trying to create a layout that looks like the component on the image.
It's a 12 col bootstrap grid. I'm looking to make the text take up 6 cols, 1 col spacer in-between the text and the last col, and then I'd like the last col (image) to take up the rest of the horizontal space, in and out of the container.
I've trying mixing the container and container-fluid classes (not advisable according to Bootstrap docs) and it doesn't work.
How would one achieve this type of a layout using Bootstrap 4?
Image:
Existing code:
<div class="info-side">
<div class="container-fluid">
<div class="row">
<div class="col-6">
<h2>#Model.TitleText</h2>
<p>#Model.AreaText</p>
</div>
<div class="col-1">
</div>
<div class="col-5">
<img src="#Model.Image.Url)" alt="#Model.Image.AlternativeText" style="width: 100%; height:100%;">
</div>
</div>
</div>
</div>
try this
<div class="info-side" >
<div class="container">
<div class="row col">
<div class="col-6 bg-info">
<h2>#Model.TitleText</h2>
<p>#Model.AreaText</p>
</div>
<div class="col-1 bg-warning">
</div>
<div class="col-5 bg-info">
<img src="#Model.Image.Url)" alt="#Model.Image.AlternativeText" style="width: 100%; height:100%;">
</div>
</div>
</div>
</div>
I added col to class row #div tag. It expands to all space available.
In another hand, mix containers regular and fluid is possible, but you have to take care of hierarchy: fluid is widest as regular, so regular must be included alone or inside a fluid class.
See this answer: link
Good Luck!
I've come to the following solution which creates the layout in my original image in the question.
I had to make one row position absolute, this way the two containers are overlapping each other.
<div class="info-side">
<div class="text-side container" style="position: relative;" >
<div class="text-area" style="position: absolute;">
<div class="row">
<div class="col-6 d-flex align-items-center" style="height: 600px;">
<div class="text-items">
<h2>#Model.TitleText</h2>
<p>#Html.Raw(Model.AreaText)</p>
</div>
</div>
</div>
</div>
</div>
<div class="image-side container-fluid">
<div class="row">
<div class="col-7"
<div class="col-5" style="height: 600px; ">
<img src="#Model.Image.Url" alt="#Model.Image.AlternativeText">
</div>
</div>
</div>
</div>
I am using an AdminLte template, which I use as a layout. In the part where I am going to put the content it is like this:
<div class="content-wrapper">
<section class="content">
#yield('content')
</section>
<!-- /.content -->
</div>
In the view where I have the content to display I have:
#extends('layouts.app')
#section('content')
<div>
<img class="mx-auto my-auto d-block" src="{{ asset('dist/img/logo.png')}}" alt="logo" style="opacity: .2">
</div>
#endsection
When executing, the image of the logo appears centered horizontally, but vertically it appears attached to the upper margin. I've tried various shapes, but can't get it to center vertically. I can't figure out how to fix it. I will appreciate a help.
in Bootstrap 4, you can use .d-flex .align-items-center
https://getbootstrap.com/docs/4.4/utilities/flex/#align-items
The result like this:
<div class="content d-flex align-items-stretch bg-info w-100">
<div class="d-flex bg-info w-100">
<div class="d-flex align-items-center w-100">
<img class="w-100" src="https://via.placeholder.com/800x200">
</div>
</div>
</div>
Here full demo
https://jsfiddle.net/herupurwito/8oq67jcr/3/
I have minimal CSS and HTML knowledge and would like to achieve the following: I am using a WordPress theme that uses Bootstrap, and I want to create a row with two columns. Left column has an image, right column has a headline that should be vertically centered. I am using a column shortcode
<div class="row">
<div class="col-6">
IMAGE
</div>
<div class="col-6">
HEADLINE
</div>
</div>
Can anyone help me how to center my headline vertically?
Thank you for your help.
If you are using Bootstrap 4. You can use the below snippet
<div class="row">
<div class="col-6">
<img src="" alt="">
</div>
<div class="col-6 d-flex align-items-center">
Your heading
</div>
</div>
If you are using Bootstrap 3.x.x. You can use the below snippet
<div class="row">
<div class="col-sm-6">
<img src="" alt="">
</div>
<div class="col-sm-6 flex-vcenter">
Your heading
</div>
</div>
CSS (only if Bootstrap ver is 3)
.flex-vcenter {
display: flex
align-items: center
}