I am trying to put 5 div elements next to each other and also center them. However, I cant make it work. Here is my code
<div style="width:200px;margin-right:20px;">
<div class="panel panel-default text-center" style="border: 1px solid #fab05d;border-radius:0px;">
<div class="panel-heading" style="background-color:#fab05d;color:#ffffff !important;border-radius:0px;">
<h1>2017</h1>
<p style="line-height: 14pt; margin-top:3px;margin-right:25px;">EARLY BIRD*</p>
<p style="clear:both;line-height: 16pt;">GOLD PACKAGE <br>REGISTRATION**</p>
</div>
<div class="panel-body" style="padding-top:5px;">
<p style="color:#929393;font-size:15px;"><strong>$x.00 TICKET</strong></p>
<div style="display:inline-block;margin:auto;padding-top:1px;margin-top:1px;" class="text-center">
<input type="image" src="http://localhost/wordpress/wp-content/uploads/2017/03/gold_remove.png" id="gold_r" style="">
<input type="text" class="text-center" id='goldval' name="quantity" size="5" onchange="gold_change()" style="vertical-align:top;font-weight:bold;border-radius:5px;border:1px solid #929393;">
<input type="image" src="http://localhost" id="gold_a" style="">
</div>
</div>
</div>
I have 5 of them. They are basically the same, only the content is different. All 5 divs are inside container-fluid (I am using bootsrap). I have tried to add display:inline-block to my container but it doesn't work. Also, I used float:left but in that case, I can't properly align my divs when the screen size changes. I tried to use the extended version of Bootstrap grid when you can create equal 5 columns but in that case, my div's content gets messed up. Can anyone please give me some solution that will work for all screen sizes? Thanks
Try this in a larger screen, I think this will work. The snippet's screen is very small that's why it does not align together. Use Media Queries to adjust the div's size so that it can accommodate smaller screen size
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container">
<div class="row">
<div style="width:200px;height:250px;margin-right:20px; border: 1px solid red;" class="col-xs-2">
</div>
<div style="width:200px;height:250px;margin-right:20px; border: 1px solid red;" class="col-xs-2">
</div>
<div style="width:200px;height:250px;margin-right:20px; border: 1px solid red;" class="col-xs-2">
</div>
<div style="width:200px;height:250px;margin-right:20px; border: 1px solid red;" class="col-xs-2">
</div>
<div style="width:200px;height:250px;margin-right:20px; border: 1px solid red;" class="col-xs-2">
</div>
</div>
</div>
This may help you!
.col-xs-2{
background:green;
color:#FFF;
}
.col-half-offset{
margin-left:4.166666667%
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row" style="border: 1px solid black">
<div class="col-xs-2" id="p1">One</div>
<div class="col-xs-2 col-half-offset" id="p2">Two</div>
<div class="col-xs-2 col-half-offset" id="p3">Three</div>
<div class="col-xs-2 col-half-offset" id="p4">Four</div>
<div class="col-xs-2 col-half-offset" id="p5">Five</div>
<div>lorem</div>
</div>
</div>
Related
This is the output when I process my code:
I want to make the border of the image to be black. How can I change that ?
<section style="background: #dfe6e9;" class="p-3">
<div class="container">
<div class="row">
<div class="col-md-6">
<img src="Profile-pic.jpg" width="500em" class="rounded-circle img-fluid img-thumbnail">
</div>
<div class="col-md-6">
</div>
</div>
</div>
</section>
You can add style to the img as
<section style="background: #dfe6e9;" class="p-3">
<div class="container">
<div class="row">
<div class="col-md-6">
<img src="Profile-pic.jpg" width="500em" class="rounded-circle img-fluid img-thumbnail" style = "border: 2px solid #000000">
</div>
<div class="col-md-6">
</div>
</div>
</div>
</section>
Well, you can add your own class to the img, or an ID, and just add
border: 1px solid black
well to really achieve what you want, just add some id to the picture (so only this one's borded changes) and change .img-thumbnail's background-color in additional the css
<style>
#my-image.img-thumbnail {
background-color: black;
}
</style>
This is the code , so can anyone help me why im not seeing bootstrap alert when i click the button , it wont show on the page !
<!DOCTYPE html><html lang="en"><head><script type="text/javascript">$(document).ready(function(){
$('button').click(function(){
$('.alert').show()
}) });</script><title>Bootstrap Example</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
.alert{display: none;}
</div>
<div class="col-md-6">
<div style="border: 1px solid black; height: 100px;">
</div>
<div style="border: 1px solid black; height: 100px;">
</div>
</div>
<div class="container">
<button>Send Message</button>
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
Success! message sent successfully.
</div>
</div>
its really hard when you dont provide your actual code, but... here goes an idea to achieve something similar to what is in the picture using classes from bootstrap:
<div class="container">
<div class="row">
<div class="col-md-5" style="border: 1px solid black; height: 600px;">
content here -->
</div>
<div class="col-md-7">
<div class="row">
<div class="col-md-12" style="border: 1px solid black; height: 300px;">
content here -->
</div>
</div>
<div class="row">
<div class="col-md-12" style="border: 1px solid black; height: 300px;">
content here -->
</div>
</div>
</div>
</div>
</div>
try this code in an ambient where you are pointing to bootstrap files or it will be totally wrong.
I am having problem in designing the footer same as in the image. I am new in css and bootstrap thats why don't have much knowledge. I want to design the given footer only for mobile view. For desktop the image will be different.I am confused with the horizontal partition because it will have vertical partition in desktop
My code for desktop view is:
.btn-font {
color: white;
font-weight: bold;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="row " style=" background-color:#F2F2F2;">
<div class="col-xs-12">
<div class="container ">
<div class="row footer-border " style="margin-top: 6em; border-right: 2px solid #ccc;">
<div class="col-md-4 col-xs-12 ">
<button class="btn btn-success button-def form-text btn-font" id="button" type="submit" name="go" style="margin-top: 1.2em; height: 50px; ">Get started with MMN free</button>
</div>
<div class="col-md-8 col-xs-12 ">
<p class="slider-heading " style="margin-top: 1em;">Discover what technology can do for your NGO.</p>
</div>
</div>
<div class="row" style="margin-top: 5em; ">
<div class="col-xs-12 footer1">
<p>ManageMyNGO</p>
</div>
</div>
<div class="row">
<div class="col-xs-12 footer2">
<p>a ColoredCow product</p>
</div>
</div>
</div>
</div>
</div>
Use a CSS border. In mobile, make it a top or bottom border (so it is horizontal), and on desktop make it a left or right border (so it is vertical) with a #media query.
You may want to practice using % when inputting css. e.g.
border-right: 1%
style="margin-top: 1.3%; <br/>
As using px and em may usually damage your css from different sizes of screen.
I have the following html:
<div class="container">
<div class="row">
<div class="col-md-2">
<div class="phone-and-email">
<p>+44 (0)7950 123 456 info#example.co.uk</p>
</div>
</div>
<div class="col-md-10">
<div class="icons">
<div class="row">
<div class="col-md-4">
<img src="images/info.png" class="pull-left"/>
<p>How to buy</p>
</div>
<div class="col-md-4">
<img src="images/delivery.png" class="pull-left"/>
<p>Free Delivery</p>
</div>
<div class="col-md-4">
<img src="images/gift.png" class="pull-left"/>
<p>Gift Vouchers</p>
</div>
</div>
</div>
</div>
</div>
</div>
css:
.phone-and-email, .icons {
border-top: 2px black solid;
border-bottom: 2px black solid;
}
I can't make the left column the same height as the right, and I have tried about 5 different solutions. It does work using javascript but I'd rather use css if possible.
How it looks:
How it should look:
One possible solution is to make use of display table for the row and table-cell to achieve the equal height of both grid sections.
Check this bootply.
HTML:
<div class="container">
<div id="onerow" class="row">
<div class="col-md-2 sameheight">
<div class="phone-and-email">
<p>+44 (0)7950 123 456 info#example.co.uk</p>
</div>
</div>
<div class="col-md-10 sameheight icons">
<div>
<div class="col-md-4">
<img src="http://www.bootply.com/assets/i_lovebootstrap.png" class="pull-left">
<p>How to buy</p>
</div>
<div class="col-md-4">
<img src="http://www.bootply.com/assets/i_lovebootstrap.png" class="pull-left">
<p>Free Delivery</p>
</div>
<div class="col-md-4">
<img src="http://www.bootply.com/assets/i_lovebootstrap.png" class="pull-left">
<p>Gift Vouchers</p>
</div>
</div>
</div>
</div>
</div>
CSS:
.phone-and-email, .icons {
border-top: 2px black solid;
border-bottom: 2px black solid;
}
img{
height:20px;
width:20px;
}
#onerow{
display: table;
}
.sameheight {
float: none;
display: table-cell;
vertical-align: top;
}
I'm trying to show two divs next to each other using Bootstrap, but there is a distance between them. How can i place them exactly next to each other.
The code:
<div class="col-lg-8 col-lg-offset-2 centered">
<div style="float: left; border: 1px solid; width: 227px; height: 50px;"></div>
<div style="float: right; border: 1px solid;width: 227px; height: 50px;"></div>
</div>
Image illustration:
Look into grids in Bootstrap.
You could do something like this:
<div class="row">
<div class="col-xs-6">div 1</div>
<div class="col-xs-6">div 2</div>
</div>
Adding to Lschessinger's answer you could use offset to center the blocks. Look here under Offsetting columns
Maybe this is what you're looking for?
<style>
.border {border: 1px solid #CCC;}
</style>
<div class="row">
<div class="col-xs-2 border col-xs-offset-4">div 1</div>
<div class="col-xs-2 border">div 2</div>
</div>
Or if you have to stick to your code with the inline styles and specific widths then maybe this, you can increase the width between by increasing the width 454px to 464px for a 10px gap, and so on:
<div class="col-lg-12">
<div style="width: 454px;" class="center-block">
<div style="border: 1px solid; width: 227px; height: 50px;" class="pull-left"></div>
<div style="border: 1px solid; width: 227px; height: 50px;" class="pull-right"></div>
</div>
</div>
One approach is to have a row containing two div elements. The elements will seemingly stack next to each other due to the fact that Bootstrap is built with flexbox.
In the following example I'm using the class justify-content-center to center both elements. And col-auto that will size columns based on the natural width of their content.
div{border:1px solid blue}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.bundle.min.js"></script>
<div class="container">
<div class="row justify-content-center p-3">
<div class="col-auto">
content one
</div>
<div class="col-auto">
content two
</div>
</div>
</div>
Align the elements to the left by using justify-content-start
div{border:1px solid blue}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.bundle.min.js"></script>
<div class="container">
<div class="row justify-content-start p-3">
<div class="col-auto">
content one
</div>
<div class="col-auto">
content two
</div>
</div>
</div>
Align the elements to the right by using justify-content-end
div{border:1px solid blue}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.bundle.min.js"></script>
<div class="container">
<div class="row justify-content-end p-3">
<div class="col-auto">
content one
</div>
<div class="col-auto">
content two
</div>
</div>
</div>
Note: This codes do not have breakpoints. If you want to add breakpoints use this format: col-{breakpoint}-auto or/and justify-content-{breakpoint}-auto