bootstrap how to make two div in one line - html

I am trying to write css code according to this image:
However, I don't know how to make two divs in one line, and hard to write code to make them exactly the same, tried many times. Could someone help me on that?
Here is my code:
<div class="media-card">
<div class="row">
<div class="col-sm-4 col-md-4">
<img class="img-responsive" src="{{ asset('images/twitter-icon-lg.png') }}">
</div>
<div class="col-sm-8 col-md-8">
<div class="media">
<a class="pull-left" href="#">
<img class="media-photo" src="{{ asset('images/header.png') }}" alt="...">
</a>
<div class="media-body">
<h4 class="media-heading">Matrix User</h4>
<p><span class="">#MatrixUser</span></p>
</div>
</div>
<div><span class="">2k followers</span></div>
</div>
</div>
<div>
<p>Approval required to publish</p>
<button>Select</button>
</div>
</div>
Here is the css part:
.block-inline {
display: inline-block;
}
.media-size {
height: 120px;
width: 90px;
border: 1px solid #CCCCCC;
}
.media-photo {
width: 45px;
}

Please try below code and keep in mind media class is already in bootstrap so always use other class:
HTML
<div class="media-card">
<div class="row2">
<div class="col-sm-4 col-md-4">
<img class="img-responsive" src="{{ asset('images/twitter-icon-lg.png') }}">
</div>
<div class="col-sm-8 col-md-8 media-right">
<a class="pull-left" href="#">
<img class="media-photo" src="{{ asset('images/header.png') }}" alt="...">
</a>
<div class="media-body">
<h4 class="media-heading">Matrix User</h4>
<p><span class="">#MatrixUser</span></p>
</div>
<span class="">2k followers</span>
</div>
</div>
<p>Approval required to publish</p>
<button>Select</button>
</div>
CSS
.row2{
overflow:hidden;
}
.media-card{
width:630px;
background:#F7F7F7;
}
.media-card div{
border:1px solid #ccc;
}
.media-right{
padding-left:0px;
padding-right:0px;
}
.block-inline {
display: inline-block;
}
.media-size {
height: 120px;
width: 90px;
border: 1px solid #CCCCCC;
}
.media-photo {
width: 45px;
}

Related

How to put logo image centered above div using pure css or boostrap?

I want to place logo exactly linked linked below image (centered above div). How it can be this done using css? This template it is designed using tabler.io.
<div class="container-xl mt-3">
<div class="d-flex justify-content-center">
<div class="col-6">
<div class="card">
<div class="card-body">
<img src="{{ asset('backend/img/logo.png') }}" alt="{{ $settings->site_name }}" width="110" height="32" alt="Tabler" class="navbar-brand-image">
<div class="col-12 col-md-12 col-lg-12 col-sm-12">
<h3 class="card-title">{{ $plan_details->plan_name }}</h3>
<form action="{{route('stripe.payment.status', $paymentId )}}" method="post" id="payment-form">
#csrf
<div class="form-group">
<div class="mb-2">
<label for="card-element">
Please enter your credit card information
</label>
</div>
<div class="mb-4">
<div id="card-element" style="display: block; width: auto; padding: 0.52rem .75rem; font-size: 2rem; line-height: 1.4; color: #606060; background-color: #ffffff; background-clip: padding-box; border: 1px solid #ccced6; border-radius: .25rem; transition: border-color .20s ease-in-out,box-shadow .20s ease-in-out; box-shadow: rgb(0 0 0 / 24%) 0px 3px 8px;">
<!-- A Stripe Element will be inserted here. -->
</div>
<!-- Used to display form errors. -->
<div id="card-errors" class="text-danger" role="alert"></div>
<input type="hidden" name="plan" value="" />
</div>
</div>
<div class="">
<button
id="card-button"
class="btn btn-danger w-100"
type="submit"
data-secret="{{ $intent }}"
> {{ __('Pay Now') }} </button>
</div>
</form>
</div>
<br>
<a class="mt-2 text-muted text-underline text-center" href="{{route('stripe.payment.cancel', $paymentId )}}"><p>Cancel payment and back to home</p></a>
</div>
</div>
</div>
</div>
</div>
output of the above code it is linked below:
----CSS----
<style>
.center-elements{
display: flex;
flex-direction: column;
align-items: center;
}
.logo {
width: 100%;
float: left;
text-align: center;
}
.logo img {
position: absolute;
transform: translate(-50%, -50%);
}
</style>
----HTML----
<div class="center-elements">
<div class="logo">
<img src="myimage.png">
</div>
<div>Invoice from One Medical</div>
</div>
Use flex, but first you should have both the logo and the div inside one div tag.
Here you go:
<div class="center-elements">
<img src="logo.png" />
<div>
Invoice from One Medical
</div>
</div>
<style>
.center-elements{
display: flex;
flex-direction: column;
align-items: center;
}
</style>

Menu logos are in the center of the div but not the titles - Bootstrap

I have been trying to create a responsive menu for the mobile browser of my site and it has four links. I have given 25% width for each of them. The problem is, although its logos stay center their titles don't. You can notice for the snippet that the titles are not in the center of their div.
What is the problem here? What am I doing wrong? Can you suggest how can I keep these titles center as well?
this is the current state:
I'm trying to make it something like this:
The snippet:
.menu {
position: fixed;
bottom: 0;
width: 100%;
background-color: #434A54;
color: white;
font-size: 12px;
padding-top: 7px;
}
a.main-link:link,
a.main-link:visited {
background-color: #434A54;
color: white;
text-decoration: none;
display: inline-block;
width: 25%;
}
.logo {
width: 24px;
height: 24px;
margin-left: auto;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container menu">
<div class="row">
<a href="start.html" class="main-link">
<div class="col-3"> <img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo"/> <br>
LINK1
</div>
</a>
<a href="calculator-home.html" class="main-link">
<div class="col-3"> <img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo"/> <br>
LINK222
</div>
</a>
<a href="contact.html" class="main-link">
<div class="col-3"> <img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo"/> <br>
LINK33333
</div>
</a>
<a href="about.html" class="main-link">
<div class="col-3"> <img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo"/> <br>
LINK4444444
</div>
</a>
</div>
</div>
Columns should be direct child of rows.
Add text center class to the columns. Put the anchor tag inside of columns and make it display:block. And the image and menu title should be placed inside the anchor tag.
/*This css is not required. */
img{
width:25px;
height:25px;
}
a.main-link:link,
a.main-link:visited {
text-decoration: none;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-3 text-center">
<a href="start.html" class="main-link d-block">
<img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo " />
<div> LINK1 </div>
</a>
</div>
<div class="col-3 text-center">
<a href="start.html" class="main-link d-block">
<img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo " />
<div> LINK1 </div>
</a>
</div>
<div class="col-3 text-center">
<a href="start.html" class="main-link d-block">
<img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo " />
<div> LINK1 </div>
</a>
</div>
</div>
</div>
If you change the html code and add the image before the text inside the anchor tag then add text-align: center you'll get the same result
check my code:
.menu {
position: fixed;
bottom: 0;
width: 100%;
background-color: #434A54;
color: white;
font-size: 12px;
padding-top: 7px;
}
.main-link {
text-align: center
}
a.main-link:link,
a.main-link:visited {
background-color: #434A54;
color: white;
text-decoration: none;
display: inline-block;
width: 25%;
}
.logo {
width: 24px;
height: 24px;
margin-left: auto;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="container menu">
<div class="row">
<a href="start.html" class="main-link">
<img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo" /><br />
<span class="col-3">LINK1
</span>
</a>
<a href="calculator-home.html" class="main-link">
<img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo" /> <br>
<span class="col-3">LINK222
</span>
</a>
<a href="contact.html" class="main-link">
<img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo" /> <br>
<span class="col-3">LINK33333
</span>
</a>
<a href="about.html" class="main-link">
<img src="http://diylogodesigns.com/blog/wp-content/uploads/2016/04/google-logo-icon-PNG-Transparent-Background.png" class="logo" /><br />
<span class="col-3">LINK4444444
</span>
</a>
</div>
</div>

horizontally center multiple divs within a div in small devices (xs)

My page has 3 div(s) within a div. In tablet and desktop screens they look good (center-aligned), but on a very small device such as cellphone the inner div(s) are left aligned (I want them to be horizontally center aligned). I applied text-center, and center-block to the outer div but it does not work. Any suggestion? Here are the html, and css codes.
.img-responsive {
display: block;
max-width: 100%;
height: auto;
}
portfolio-caption {
max-width: 281px;
background-color: #994ACC;
text-align: center;
padding: 10px;
border-top: 3px solid #ffffff;
margin-bottom: 10px;
}
<div class="row">
<div class="col-md-4 col-sm-6 col-xs-12">
<div style="max-width: 281px">
<a href="#" ">
<img src="./x/pilotproject1.jpg " class="img-responsive " style="margin: 0 auto; " alt=" ">
</a>
<div class="portfolio-caption text-center ">
<strong><h4>Project Name</h4></strong>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12 ">
<div style="max-width: 281px ">
<a href="# ">
<img src="./x/pilotproject2.jpg " class="img-responsive "
style="margin: 0 auto; " alt=" ">
</a>
<div class="portfolio-caption text-center ">
<strong><h4>Project Name</h4></strong>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12 ">
<div style="max-width: 281px ">
<a href="# " class="pilot-link ">
<img src="./x/pilotproject3.jpg " class="img-responsive "
style="margin: 0 auto; " alt=" ">
</a>
<div class="portfolio-caption text-center ">
<strong><h4>Project Name</h4></strong>
</div>
</div>
</div>
</div>
The reason that I have is that the width of the pictures is 281 px, if I do not set the width, the width of the div that comes after the img will be bigger than 281 px which is not something that I want.
as you can see in this picture, the images are all left-aligned
I added a class centered as a container to center elements (please remove the border border: 1px solid red; it is used to show you the container block ):
.centered {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
border: 1px solid red;
}
.img-responsive {
display: block;
max-width: 281px !important;
height: auto;
margin: 0 auto;
}
wrap each element you want to be centered.
Also in your css portfolio-caption should be .portfolio-caption to select a class.
I moved your in-line style to css class img-responsive so you can update your style in one place.
.img-responsive {
display: block;
max-width: 281px !important;
height: auto;
margin: 0 auto;
}
.portfolio-caption {
width: 281px;
background-color: #994ACC;
text-align: center;
padding: 10px;
border-top: 3px solid #ffffff;
margin-bottom: 10px;
float: right;
}
.centered {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
/* border: 1px solid red; */
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<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>
<div class="row">
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="centered">
<a href="#">
<img src="http://placehold.it/350x150" class="img-responsive" alt=" ">
</a>
</div>
<div class="centered">
<div class="portfolio-caption text-center ">
<strong><h4>Project Name</h4></strong>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="centered">
<a href="# ">
<img src="http://placehold.it/350x150" class="img-responsive" alt=" ">
</a>
</div>
<div class="centered">
<div class="portfolio-caption">
<strong><h4>Project Name</h4></strong>
</div>
</div>
</div>
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="centered">
<a href="# " class="pilot-link ">
<img src="http://placehold.it/350x150" class="img-responsive" alt=" ">
</a>
</div>
<div class="centered">
<div class="portfolio-caption text-center ">
<strong><h4>Project Name</h4></strong>
</div>
</div>
</div>
</div>
You should not apply classes to outer divs, apply them exactly to what you want to be centered : class="img-responsive center-block", and
also check the bootstrap version center-block is new in Bootstrap version 3.0.1 i believe.
Use
Text align : center ;
text-align:center
<div style="max-width: 281px; text-align : center">
Plunker link :
https://plnkr.co/edit/UaW436KiylzfqOCU1cg1?p=preview

Vertical align of two md column with Bootstrap

I've searched and tried all Stackoverflow solutions without success.
I've this code and I'm using bootstrap3
<footer>
<div class="container">
<div class="row">
<div class="col-md-4">
<img src="Images/social/facebook.png" alt="facebook" class="footerimg" />
<img src="Images/social/twitter.png" alt="twitter" class="footerimg" />
<img src="Images/social/youtube.png" alt="youtube" class="footerimg" />
</div>
<div class="col-md-4 col-md-offset-4">
<p class="text-right">© <%: DateTime.Now.Year %> Test - All Rights Reserved</p><p class="text-right">P.IVA 123456789</p>
</div>
</div>
</div>
</footer>
I would like to vertically center col-md-4 elements and I have footer styles like this:
footer {
background-color: #000;
color: #fff;
height: 120px;
}
I've already tried with table-cell applied to col-md-4 but without success.
Can you suggest a solution?
If you want something like this : (images are not shown)
I made a live example.
This is the code :
<footer>
<div class="container">
<div class="row">
<div class="col-md-4 col-sm-4">
<div class="centered">
<img src="Images/social/facebook.png" alt="facebook" class="footerimg" />
<img src="Images/social/twitter.png" alt="twitter" class="footerimg" />
<img src="Images/social/youtube.png" alt="youtube" class="footerimg" />
</div>
</div>
<div class="col-md-4 col-sm-4 col-sm-offset-4 col-md-offset-4">
<div class="centered">
<p class="text-right">© Test - All Rights Reserved</p><p class="text-right">P.IVA 123456789</p>
</div>
</div>
</div>
</div>
</footer>
And the CSS
footer {
background-color: #000;
color: #fff;
height: 120px;
display: table;
width: 100%;
}
.centered {
display: table-cell;
vertical-align: middle;
height: 120px;
}
Ref : centering-in-the-unknown

Bootstrap align caption relative to image width not the container

I'm trying to list some images, and for each image I want to have a caption, with some details, let's say the title, the problem right now is that the width of the caption is relative to the parent div which is normal, but I want it to be relative to the image width, but since I have the class img-responsive on the img I don't know how to achive this. Maybe you guys can help me out.
Here is a live example: http://jsbin.com/cudugize/1/edit?html,css,output
Here is the code
HTML
<div class="col-sm-3 col-xs-6 col-md-2 col-lg-3">
<div class="thumbnail">
<img width="139" height="161" src="http://lorempixel.com/139/161/nightlife/" class="img-responsive" alt="...">
<div class="caption img-responsive">
<h4 class="text-center">Nice title</h4>
<p class="text-center"><span class="glyphicon glyphicon-globe"></span> usa</p>
</div>
</div>
<div class="thumbnail">
<img width="139" height="161" src="http://lorempixel.com/139/161/nightlife/" class="img-responsive" alt="...">
<div class="caption img-responsive">
<h4 class="text-center">Nice title</h4>
<p class="text-center"><span class="glyphicon glyphicon-globe"></span> usa</p>
</div>
</div>
</div>
CSS
Aditional bootstrap core css
.thumbnail{
position: relative;
width: 100%;
border: none !important;
}
.thumbnail .caption{
position: absolute;
bottom: 0px;
background: rgba(0,0,0,0.50);
width: 100%;
padding: 0px !important;
}
http://jsbin.com/cudugize/7
please see my demo code, it archived your demand.
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet" type="text/css" />
<script src="http://getbootstrap.com/dist/js/bootstrap.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style>
.tc {
text-align:center;
}
.thumbnail {
position: relative;
display:inline-block;
*display:inline;
*zoom:1;
border: none;
margin:0 auto;
padding:0;
}
.thumbnail .caption {
position: absolute;
bottom: 0px;
background: rgba(0, 0, 0, 0.50);
width: 100%;
padding: 0px !important;
}
</style>
</head>
<body>
<div class="col-sm-3 col-xs-6 col-md-2 col-lg-3">
<div class="tc">
<div class="thumbnail">
<a href="url">
<img width="139" height="161" src="http://lorempixel.com/139/161/nightlife/" class="img-responsive" alt="...">
</a>
<div class="caption img-responsive">
<h4 class="text-center">Nice title
</h4>
<p class="text-center">
<a href="#" class="homepage city text-uppercase">
<span class="glyphicon glyphicon-globe"></span>usa</a>
</p>
</div>
</div>
</div>
<div class="tc">
<div class="thumbnail">
<a href="url">
<img width="139" height="161" src="http://lorempixel.com/139/161/nightlife/" class="img-responsive" alt="...">
</a>
<div class="caption img-responsive">
<h4 class="text-center">Nice title
</h4>
<p class="text-center">
<a href="#" class="homepage city text-uppercase">
<span class="glyphicon glyphicon-globe"></span>usa</a>
</p>
</div>
</div>
</div>
</div>
</body>
</html>
This CSS should do the trick:
.thumbnail {
display: inline-block;
position: relative;
border: none !important;
padding: 0;
}
.thumbnail .caption{
position: absolute;
bottom: 0px;
background: rgba(0,0,0,0.50);
width: 100%;
padding: 0px !important;
}