I just joined StackOverflow since I recently got back to webdesign and I'm learning Bootstrap. I'm designing my own Website and I'm already facing an issue that I can't resolve myself. I want to achieve the following: Workflow I also would like to make the arrows disappear when the screen size gets so small that make the icons look in a vertical way instead of the regular horizontal way (hope I explained it correctly)
I already tried some things and failed:
1- Instead of using each icon/arrow in a separate img file, I saved them in a unique img file and used the css "img-responsive" class. It looked pretty good on desktop but text looked too small on mobile.
2- After that I got back to trying to make it work with each img in a separate file, I found a post here about getting 7 equal columns and it seems to do what I need but I can't get the images to be close enough as I want to, tried several ways to remove the gutter between the columns and nothing, I think that it might be cause to get the 7 equal columns, the columns itself get a fixed width, not allowing me to get rid of their padding/margin.
Here's what I've got so far:
HTML:
<div id="whyus" class="container-fluid text-center">
<h2>Why Us?</h2>
<div class="row seven-cols">
<div class="col-md-1 no-padding">
<img src="img/Heart_icon.png">
<h4>Passion</h4>
</div>
<div class="col-md-1 no-padding">
<img src="img/Arrow1.png" class="arrow1">
</div>
<div class="col-md-1 no-padding">
<img src="img/Idea_icon.png">
<h4>Ideas</h4>
</div>
<div class="col-md-1 no-padding">
<img src="img/Arrow2.png" class="arrow2">
</div>
<div class="col-md-1 no-padding">
<img src="img/Brain_icon.png">
<h4>Work</h4>
</div>
<div class="col-md-1 no-padding">
<img src="img/Arrow1.png" class="arrow1">
</div>
<div class="col-md-1 no-padding">
<img src="img/Like_icon.png">
<h4>Amazing Results</h4>
</div>
</div>
CSS:
.arrow1 {
padding-top: 75px;
}
#media only screen and (max-width: 768px) {
.seven-cols .col-md-1,
.seven-cols .col-sm-1,
.seven-cols .col-lg-1 {
width: 100%;
*width: 100%;
}
}
#media (min-width: 992px) {
.seven-cols .col-md-1,
.seven-cols .col-sm-1,
.seven-cols .col-lg-1 {
width: 14.285714285714285714285714285714%;
*width: 14.285714285714285714285714285714%;
}
}
#media (min-width: 1200px) {
.seven-cols .col-md-1,
.seven-cols .col-sm-1,
.seven-cols .col-lg-1 {
width: 14.285714285714285714285714285714%;
*width: 14.285714285714285714285714285714%;
}
}
And this is how it's looking so far: Website Preview
Sorry for not uploading the code into the snippet, tried but couldn't get it to work so hope you guys get the idea anyway... BIG THANKS!
EDIT:
-ARROWS: arrow1.png arrow2.png (modified the arrows in the code cause I just realized that arrow1 and arrow3 are the same one... I also want to mention that I gave them a class in order to add some padding to them, so they can look like I showed at the beginning of the post in Workflow)
How about this?
Instead of calculating and allocating each item a width, using flex display on seven-cols and flex:1 on the seven-cols divs to make it flexibly grow and shrink.
When the max-width reaches a certain width threshold, change the flex-direction to column and hide the arrows.
.arrow1 {
padding-top: 75px;
}
#media only screen and (max-width: 768px) {
.seven-cols {
display: flex;
flex-direction: column;
}
.arrow1,
.arrow2 {
display:none;
}
}
#media (min-width: 769px) {
.seven-cols {
display: flex;
justify-content: center;
}
.seven-cols>* {
flex: 1;
max-width: 14%;
}
.no-padding .arrow1,
.no-padding .arrow2 {
width: 80%;
}
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.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>
<div id="whyus" class="container-fluid text-center">
<h2>Why Us?</h2>
<div class="row seven-cols">
<div class="no-padding">
<img src="http://via.placeholder.com/100x100">
<h4>Passion</h4>
</div>
<div class="no-padding">
<img src="https://i.stack.imgur.com/QqJno.png" class="arrow1">
</div>
<div class="no-padding">
<img src="http://via.placeholder.com/100x100">
<h4>Ideas</h4>
</div>
<div class="no-padding">
<img src="https://i.stack.imgur.com/17ox3.png" class="arrow2">
</div>
<div class="no-padding">
<img src="http://via.placeholder.com/100x100">
<h4>Work</h4>
</div>
<div class="no-padding">
<img src="https://i.stack.imgur.com/QqJno.png" class="arrow1">
</div>
<div class="no-padding">
<img src="http://via.placeholder.com/100x100">
<h4>Amazing Results</h4>
</div>
</div>
CSS:
Related
This question already has answers here:
Order columns through Bootstrap4
(6 answers)
Closed 3 years ago.
I have to divs next to each other in a row div. On mobile, i want the right_side div(col-md-9) to be the first div.
I tryed ordering it with flex, but it messed up all my site.
<div class="row">
<div class="col-md-3">Left side</div>
<div class="col-md-9">Right side, but first on mobile or tablet</div>
<div class="clearfix"></div>
</div>
If i am viewing the site on mobile or tablet, i want the col-md-9 div as first div.
#media screen and (max-width: 767px) {
.col-md-3 {
order: 2;
}
.col-md-9 {
order: 1;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<div class="row">
<div class="col-md-3">Left side</div>
<div class="col-md-9">Right side, but first on mobile or tablet</div>
<div class="clearfix"></div>
</div>
there is an option to reverse the row using class. here is the code please try it once.
<div class="row flex-row-reverse">
<div class="col-md-9">Right side, but first on mobile or tablet</div>
<div class="col-md-3">Left side</div>
<div class="clearfix"></div>
</div>
Just use order property.
#media only screen and (max-width: 760px) {
.col-md-3 {
order:2;
}
}
#media only screen and (max-width: 760px) {
.col-md-3 {
order:2;
}
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="row">
<div class="col-md-3">Left side</div>
<div class="col-md-9">Right side, but first on mobile or tablet</div>
<div class="clearfix"></div>
</div>
Use Column Ordering to accomplish this.
col-md-push-6 will "push" the column to the right 6 and col-md-pull-6 will "pull" the column to the left on "md" or greater view-ports. On any smaller view-ports the columns will be in normal order again.
I think what throws people off, is that you have to put B above A in your HTML. There may be a different way to do this where A can go above B in the HTML, but I'm not sure how to do it...
See Code
<div class="row">
<div class="col-md-6 col-md-push-6">B</div>
<div class="col-md-6 col-md-pull-6">A</div>
</div>
view-port >= md
|A|B|
view-port < md
|B|
|A|
you can do with flex and order as below example.
If it is messing-up with all sites, then give your custom class and then give CSS.
#media screen and (max-width: 531px) {
.row { display: flex; flex-direction: column; }
.two { order: 1; }
.one { order: 2 }
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css">
<div class="row">
<div class="col-md-3 one">Left side</div>
<div class="col-md-9 two">Right side, but first on mobile or tablet</div>
<div class="clearfix"></div>
</div>
I'm trying to hide text content on splash screen of website. How to hide it with css or html code?
This is for perl based script with html and css based splash screen on homepage. This is the website. You can see the texts are messed on mobile devices.
I've tried below code to hide text on mobile:
#media only screen and (max-width: 800px) {
#content {
display: none;
}
}
into this code:
</br>
<div id="content">
<div class="container" style="position: relative;top: 50%; transform: translateY(15%)">
<div class="prompic" style="">
</div>
<div class="splashbar promsign">
<a href="<TMPL_VAR site_url>/register.html">
<div class="col">
<div class="pheader">
<span><img src="<TMPL_VAR site_url>/images/icon_sup_blue.png"></span>
<span>SignUp</span>
<div class="clear">
Whenever you need to send a file that is too large for e-mail, <b><TMPL_VAR site_name></b> can help. If you need secure remote storage capacity for off-site backups, <b><TMPL_VAR site_name></b> offers best solutions for you.
</div>
</div>
</div>
</a>
</div>
<div class="splashbar promprofit">
<a href="<TMPL_VAR site_url>/make_money.html">
<div class="col">
<div class="pheader">
<span><img src="<TMPL_VAR site_url>/images/icon_profit_blue.png"></span>
<span>Become Affiliate</span>
<div class="clear">
With <b><TMPL_VAR site_name></b> you can earn money by promoting your files on the external resources. Just register and enjoy being a part of one or more of our affiliate programs!
</div>
</div>
</div>
</a>
</div>
<div class="clear"></div>
</div>
<div class="col-12 lft splashHldr">
<img src="/images/android.png" height="61">
<img src="/images/mac_os.png" height="61">
<img src="/images/windows.png" height="61">
</div>
</br>
<div id="content" style="width: 980px">
<div class="col">
<div class="clear">
</div>
</div>
<b><TMPL_VAR site_name></b> is a cloud-based file hosting provider. We offer online cloud storage/remote backup capacity, sophisticated uploading and downloading tools.
</div>
</a>
<style>
body{background-image:url(../images/bg.png); -webkit-background-size:cover; -moz-background-size:cover; -o-background-size:cover; background-size:cover;}
#header{background:none!important; border:0px!important;}
footer{background:none; border:0px;position:absolute;bottom:0px;}
footer .container1{display:none;}
#mainmenu ul li a{color:#fff;}
.copyright{display:block;}
.prompic{margin: 50px auto 30px;}
#media (min-width: 320px) and (max-width: 480px) {
#container{margin:0px auto;}
.prompic{margin: 10px auto 10px;}
}
#media (min-width: 600px) and (max-width: 800px) {
#container{margin:0px auto;}
}
#media only screen and (max-width: 800px) {
#content {
display: none;
}
}
</style>
I expect to hide these messy texts on mobile devices but it didn't take any effect.
How to do it properly?
min-width: 800px selects screens with a width of 800px or higher. Try max-width instead:
#media only screen and (max-width: 800px) {
...
`https://codepen.io/kunalvijan/pen/oRmRwp`
i have created a dummy codepen for you. just check and see if the solution works for you
I'm using Bootstrap 3.3.7 and flexbox. I've got flexbox working on a 3 column (3 .col-md-3 inside a .container-fluid) working.
But I want to collapse the columns (each .col-md-3) into single columns on mobile.
How can I do this? My markup is as follows:
<div class="container-fluid">
<div class="row flex text-center">
<div class="col-md-3 software-box-outer">
<h1>
Testing 1
</h1>
</div>
<div class="col-md-3 software-box-outer">
<h1>
Testing 2
</h1>
</div>
<div class="col-md-3 software-box-outer">
<h1>
Testing 3
</h1>
</div>
</div>
</div>
CSS:
.flex {
display: flex;
justify-content: space-between;
}
.row.flex:before,
.row.flex:after {
display: none;
}
.software-box-outer {
height: 200px;
border: 3px solid grey;
}
Fiddle is here: https://jsfiddle.net/xpufcsuk/
I tried adding .col-xs-12 to each .col-md-3 hoping this would make it go into full single columns (occupy all 12 cols) on mobile. But it doesn't.
You can use #media queries to make your website responsive.
#media (max-width: 760px) {
.flex {
flex-direction:column; //change the flex direction from row to column
}
}
Basically, when the screen-size is lower than 760px, you change direction to column
Example: ( lower resolution to 760px )
https://jsfiddle.net/972bdkvr/1/
If you want flexbox to work on only large deceives, you can use media queries.
Write you code into #media screen and (min-width:767px), so it will work only when device width > 767px
#media screen and (min-width:767px) {
.flex {
display: flex;
justify-content: space-between;
}
.row.flex:before,
.row.flex:after {
display: none;
}
}
.software-box-outer {
height: 200px;
border: 3px solid grey;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid">
<div class="row flex text-center">
<div class="col-md-3 software-box-outer">
<h1>
Testing 1
</h1>
</div>
<div class="col-md-3 software-box-outer">
<h1>
Testing 2
</h1>
</div>
<div class="col-md-3 software-box-outer">
<h1>
Testing 3
</h1>
</div>
</div>
</div>
I'm trying to create a responsive header in my app with the following elements:
a logo (<img>)
a search bar (<input>)
a link (<a>)
two boxes (<div>)
Elements position depends of the screen size:
Medium screens (md-*)
Small screens (sm-*)
Extra small screens (xs-*)
I manage to create each of these layouts, but not with the responsive classes of Bootstrap... Can you help me here?
Here is the simple code I used to make this example:
<div class="container">
<div class="row vertical-aligned">
<!-- Logo -->
<div class="col-md-2 col-sm-12 col-xs-12">
<img class="logo" src="http://pngimg.com/upload/cocacola_PNG14.png"/>
</div>
<!-- Search bar -->
<div class="col-md-7 col-sm-6 col-xs-12">
<div class="input-group search-width">
<input type="text" class="form-control"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-search"></span>
</span>
</div>
<a>Launch advanced research...</a>
</div>
<!-- Nav boxes -->
<div class="col-md-3 col-sm-6 col-xs-12">
<div class="nav-button">Profil</div>
<div class="nav-button">Settings</div>
</div>
</div>
</div>
JSFiddle here
I solved the issue, i found 2 problems.
The first one with your md screen, the input field and the paragraph would not stay inline, because of the float property, this would be solved by editing the css of the .input-group class as float left. The second problem for the small screen, is that the div will not stack over one other with a 100% width because you set the css property display: flex and center, I created a media query for the window size of small (<768px) to display those div as inline-block. Please comment for any additional help or problems, the code below should be working fine.
UPDATE - Solving the additional requirements for the md and sm size:
For the first problem i added padding top to the id=link, in a media query that will target only md devices, for the second problem with media queries i edited the position of those divs with position relative and left/top attributes.
Thanks
Fabrizio Bertoglio
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link href="main.css" rel="stylesheet" />
</head>
<body>
<div class="container">
<div class="row vertical-aligned">
<!-- Logo -->
<div class="col-md-2 col-sm-12 col-xs-12">
<img class="logo" src="http://pngimg.com/upload/cocacola_PNG14.png"/>
</div>
<!-- Search bar -->
<div class="col-md-7 col-sm-12 col-xs-12">
<div class="row">
<div class="input-group col-md-6">
<input type="text" class="form-control"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-search"></span>
</span>
</div>
<div class="col-md-4" id="link">
<a>Launch advanced research...</a>
</div>
</div>
</div>
<!-- Nav buttons -->
<div class="col-md-3 col-sm-12 col-xs-12" id="boxes">
<div class="nav-button">Profil</div>
<div class="nav-button">Settings</div>
</div>
</div>
</div>
Css Code
</body>
</html>
.vertical-aligned {
display: flex;
align-items: center;
}
.logo {
width: 100%;
display: block;
}
.nav-button {
height: 70px;
width: 80px;
border: solid 1px black;
display: inline-block;
}
.input-group {
float: left !important;
}
#media (min-width: 992px) {
#link {
padding-top: 6px;
}
}
#media (max-width: 768px) {
.vertical-aligned {
display: inline-block;
}
#boxes {
max-width: 300px;
position: relative;
left: 100%;
transform: translateX(-179px);
top: -5%;
}
a {
position: relative;
top: 49px;
}
}
I hope this answer can help you.
You can use #media to manage every element size in different layout,
for example, on laptop layout:
#media screen
and (min-device-width: 1200px)
and (max-device-width: 1600px)
and (-webkit-min-device-pixel-ratio: 1) {
//your css here
}
/* ----------- Retina Screens ----------- */
#media screen
and (min-device-width: 1200px)
and (max-device-width: 1600px)
and (-webkit-min-device-pixel-ratio: 2)
and (min-resolution: 192dpi) {
//your css code here
}
https://css-tricks.com/snippets/css/media-queries-for-standard-devices/
https://www.youtube.com/watch?v=t526Lt_O7zo
I have been reading a lot of documentation but I cannot succeed re-arranging some divs order. This is my code
<div class="container">
<div class="row">
<div class="col-md-11">
<div class="slider">
The slider
</div>
</div>
<div class="col-md-5">
<nav class="main-menu">
The Menu
</nav>
</div>
</div>
</div>
I want the menu to be over the slider (both with 16 column size) when screen enters sm. Is it possible?
Use flexbox:
.row {
display: flex;
flex-direction: column;
}
#media (max-width: 500px) {
.row > div:first-child {
order: 2;
}
}
http://codepen.io/antibland/pen/aNRZRJ