i have a bootstrap page where i am trying to display images inside bootstrap columns, i did the following code:
<!DOCTYPE html>
<html lang="en">
<head>
<title></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.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="row">
<?php for($i=1;$i<=19;$i++){?>
<div class="col-sm-12 col-lg-4" style="text-align:center">
<img src="n<?=$i?>.jpg" class="img-responsive">
</div>
<?php } ?>
</div>
</body>
</html>
there are 19 images, everything is coming fine except the 7th image which is coming in a single row in large screens. this is the live link:enter link description here
can anyone please tell me what is wrong in here?
Since your code uses bootstrap 3, so flexbox is not used by default.
Bootstrap V3:
<div class="row" style="display:flex; flex-flow:row wrap;">
<?php for($i=1;$i<=19;$i++){?>
<div class="col-sm-12 col-lg-4" style="text-align:center">
<img src="n<?=$i?>.jpg" class="img-responsive">
</div>
<?php } ?>
</div>
Better to use bootstarp v4 or v5 with flexbox support so there is no need for the extra CSS.
Bootstrap V4 and V5:
<div class="row">
<?php for($i=1;$i<=19;$i++){?>
<div class="col-sm-12 col-lg-4" style="text-align:center;">
<img src="n<?=$i?>.jpg" class="img-fluid">
</div>
<?php } ?>
</div>
Related
I'm new to bootstrap, trying to align 2 divs vertical on responsive mode, but no luck so far.
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
</head>
<body>
<div>
<div class="col-xs-12 col-sm-1" ><i class="material-icons">cloud</i>
</div>
<div class="col-xs-12 col-sm-11">
<p>The estimated delivery date is provided to you as a guide only.</p>
</div>
</div>
</body>
On normal desktop mode, the divs are vertically aligned. But once I go to mobile mode, the second div is sitting below the first div. How can I make the 2nd div to sit next to the first div vertically?
Most of the boostrap over mobile devices tend to make things one below another because that is pretty much what bootstrap does in CSS/Div elements on mobile.
There are some solutions over it, but I see in your elements before
<div class="col-xs-12 col-sm-1" ><i class="material-icons">cloud</i>
that you don't use the triple rule.
Using bootstrap col- elements should be always into container and row like this:
<div class="container"> <!-- Or container-fluid -->
<div class="row">
<div class="col-xs-12 col-sm-1">
most inner div
<div/>
<div/>
<div/>
A little harder as solution is to copy the whole Bootstrap grid css file into a new file you make and you modify the things you need the most, like the .col-lg xs or the flex and the max width
Last but not least, go check the #media element over here:
https://www.w3schools.com/css/css_rwd_intro.asp
This could help you understand the most of what I said before about auto-resizing over mobile devices and css elements
<!--Try this one, It's simple and responsive in all widths and are aligned vertically can also do this using css flex box but little bit lengthy.-->
<!doctype html>
<html lang="en">
<head>
<title>Title</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
<div class="container mt-5">
<div class="col-md-12">
<div class="d-flex flex-column">
<img src=" https://i.ytimg.com/vi/hF_LjTUvP-U/maxresdefault.jpg" alt="firstImg" class="img-fluid" style="width: 150px;
height: 150px;">
<img src="https://wallpapercave.com/wp/wp2554641.jpg" alt="secondImg" class="img-fluid mt-2" style="width: 150px;
height: 150px;">
</div>
</div>
</div>
</body>
</html>
strong text
You wrote
<div class="col-xs-12 col-sm-1" >
The col-xs-12 means, that on small screens, this element should fill the complete container. Use
<div class="col-xs-6 col-sm-1" >
for both containers, or one col-xs-1 and the other col-xs-11.
There are 12 columns in bootstrap and you decide, how they are filled
I'm reworking an existing module to make it more adaptive. Below is a general mock-up of the current design. This design is used for multiple things, and the goal is that adding or removing modules should be easy.
Right now, we're using a HTML <table> to achieve the lay-out, using col-span and row-span everywhere, but that becomes very messy, very fast (especially if we want to remove a module, or add another module of a different size).
What would a proper way to work around this, be? I'm not looking after a full solution, I'd rather have a small example that I can extend on.
I tried Bootstrap, but some of the modules have fixed sizes, which messes up the GRID-design of Bootstrap. Float has issues with the vertical stacking, ...
Code snippet of how it's created right now:
<table>
<tbody>
<tr>
<td colspan="4" rowspan="2">module</td>
<td>module</td>
<td colspan="3" rowspan="2">module</td>
</tr>
<tr><td>module</td></tr>
</tbody>
</table>
Customize grid according to your needs
<!DOCTYPE html>
<html lang="en">
<head>
<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">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container-fluid">
<h1>Hello World!</h1>
<p>Resize the browser window to see the effect.</p>
<div class="row">
<div class="col-sm-3" style="background-color:lavender;">.col-sm-3</div>
<div class="col-sm-6" style="background-color:lavenderblush;">.col-sm-6</div>
<div class="col-sm-3" style="background-color:lavender;">.col-sm-3</div>
</div>
<div class="row">
<div class="col-sm-6" style="background-color:black;">.col-sm-6</div>
<div class="col-sm-3" style="background-color:green;">.col-sm-3</div>
<div class="col-sm-3" style="background-color:blue;">.col-sm-3</div>
</div>
</div>
<div class="row">
<div class="col-sm-6" style="background-color:red;">.col-sm-6</div>
<div class="col-sm-3" style="background-color:pink;">.col-sm-3</div>
<div class="col-sm-3" style="background-color:yellow;">.col-sm-3</div>
</div>
</div>
</body>
</html>
I am new to LESS, started working with it and the issue I am facing is that I can't get the bootstrap row/column to work. I want three thumbnails to appear side by side (i.e. three columns in one row) but it won't happen. Is it because I have messed up any of the LESS files?
Here is my code:
<!DOCTYPE html>
<html>
<head>
<title>Home</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href='https://fonts.googleapis.com/css?family=Roboto:900,700,400,500|Open+Sans:400,700,300|Oxygen:400,300,700' rel='stylesheet' type='text/css'>
<!-- the bootstrap compiled file outputted from LESS -->
<link href="_/css/bootstrap.css" rel="stylesheet" media="screen">
<!-- compiled version of my styles, outputted from LESS file where I edit my styles -->
<link href="_/css/mystyles.css" rel="stylesheet" media="screen">
</head>
<body>
<section class="container">
<h2>Heading</h2>
<div class="row">
<div class="col-md-3">
<a href="#" class="thumbnail">
<img src="images/blacksea.jpg" alt="...">
</a>
</div> <!-- thumbnail 1 -->
<div class="col-md-3">
<a href="#" class="thumbnail">
<img src="images/blacksea.jpg" alt="...">
</a>
</div> <!-- thumbnail 2 -->
<div class="col-md-3">
<a href="#" class="thumbnail">
<img src="images/blacksea.jpg" alt="...">
</a>
</div> <!-- thumbnail 3 -->
</div> <!-- row -->
</section> <!-- container -->
<script src="js/bootstrap.js"></script>
<script src="js/myscript.js"></script>
</body></html>
I tested my code on a normal boostrap setup (without Less) and it is working perfectly fine. But when the same code in my LESS set up the pictures get stacked vertically rather than horizontally.
Having seen it work on jsfiddle, I think the reason it is not working locally is because there may be some issue with my Bootstrap import, because for a verification, when I tried to do this feature of Bootstrap it did not work and I got this instead, so something to do with Bootstrap?
Thank you in advance!
I have 3 blocks of data. First one having grid size of 10, second also size of 10 and third having size of 2.Can i pull the third grid 20 times to make it the 1st grid?
At first its like
then i want the result like
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<style>
.a{
background:blue;
}
.b{
background:red;
}
.c{
background:green;
}
</style>
</head>
<body>
<div class="row">
<div class="c col-xs-12 col-sm-10">Graph</div>
<div class="b col-xs-12 col-sm-10">Meters</div>
<div class="a col-xs-12 col-sm-2">Buttons</div>
</div>
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</body>
</html>
I want to put the buttons before graph in screen size greater than xs
You need to use two different set of buttons. One that will be placed before the graphs and will be visible only in larger that xs screens, and one the will be placed after the graphs and will only be visible in xs screens.
Example:
<div class="row">
<div class="a col-xs-12 col-sm-2 hidden-xs">Buttons</div>
<div class="c col-xs-12 col-sm-10">Graph</div>
<div class="col-xs-12 col-sm-2 hidden-xs"></div>
<div class="b col-xs-12 col-sm-10">Meters</div>
<div class="a col-xs-12 col-sm-2 visible-xs">Buttons</div>
</div>
Working fiddle
Here is my bootstrap HTML code snippet. It is working fine in all browsers except in IE-11 . I am getting a horizontal scrollbar also the last 2 div col-xs-6 inside a row are coming in 2 different rows not in a single row.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="javascript/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="row" style="background-color:yellow;">
<div class="col-xs-12" style="background-color:aqua;">col-xs-12 inside a row</div>
</div>
</div>
<div class="container">
<div class="row" style="background-color:yellow;"> direct inside a row
</div>
</div>
<div class="container">
<div class="row" style="background-color:yellow;">
<div class="col-xs-6" style="background-color:red;">col-xs-6 inside a row</div>
<div class="col-xs-6" style="background-color:orange;">col-xs-6 inside a row</div>
</div>
</div>
</body>
</html>
Thanks for the help in advance.
You can try to specify the compatibility mode in the document header with:
<meta http-equiv="X-UA-Compatible" content="IE=11" />
Take a look to this link for more info:
IE legacy document modes