is there a way using css to shift rows down the container when using #media originally two columns per row (3 rows total),need 1 column only when resized to multiple widths ex: 980, 760px, etc. (making 5 lines or rows). Thanks for any help
<div class="container">
<div id="portfolio" class="col-sm-6">
<div class="row">
<h1>Portfolio</h1>
</div>
<br />
<div class="realign">
<div class="row">
<div class="col-sm-6">
<div id="gym"><span class="text">Gym</span></div>
</div>
<div class="col-sm-6">
<div id="hiking"><span class="text">Hiking</span></div>
</div>
<div class="row">
<div class="col-sm-6">
<div id="overwatch"><span class="text">Overwatch</span></div>
</div>
<div class="col-sm-6">
<div id="running"><span class="text">Running</span></div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div id="programming"><span class="text">Programming</span></div>
</div>
</div>
</div>
</div>
</div>
/* Portfolio Only*/
#gym {
background-image: url("images/gym.jpg");
height: 150px;
width: 150px;
}
#hiking {
background-image: url("images/hiking.jpg");
height: 150px;
width: 150px;
margin-bottom: 15px;
margin-left: 15px;
}
#overwatch {
background-image: url("images/overwatch.jpg");
height: 150px;
width: 150px;
margin-left: 15px;
margin-bottom: 15px;
}
#running {
background-image: url("images/running.jpg");
height: 150px;
width: 150px;
padding: 0;
margin-left: 15px;
}
#programming {
background-image: url("images/programming.jpg");
height: 150px;
width: 150px;
margin-left: 15px;
}
#portfolio {
background-color: #ffffff;
padding: 20px;
}
.text {
background-color: #4aaaa5;
color: #ffffff;
width: 150px;
position: absolute;
text-align: center;
top: 120px;
font-family: 'Georgia', Times, "Times New Roman", serif;
}
/* #Media Settings */
#media screen and (max-width: 980px) {
body { width: 100%; }
.linebreak {margin-top: 300px;}
#bio img {margin-left: 50px;}
.realign {
}
/* check if its working */
.footnote {width: 50%;}
You already have classes with names such as col-sm-6, so I'm assuming you're using Bootstrap. That will handle most responsiveness automatically for you, by simply using col-sm (small screens), col-md (medium size screens), and col-lg (large screens). Simply make each row have column widths that add up to 12.
In your case, it sounds like you want to give everything that currently has <div class="col-sm-6"> a class that instead is:
<div class="col-sm-12 col-md-6">
That will result in two columns per row on laptops and desktops, with one column per row on mobile devices.
However, assuming you want to override BootStrap classes (or use your own class with the same name), here's an alternative solution.
First, set a default width of 50% for the class, and apply a float, so that two columns will be next to each other:
.col-sm-6 {
width: 50%;
float: left;
}
Then make said columns occupy 100% of the width at certain screen widths:
#media screen and (max-width: 980px) {
.col-sm-6 {
width: 100%;
}
}
Hope this helps!
Related
I guess this might be impossible, but perhaps any expert can help me out with this. I'm trying to get a quite simple reponsive behaviour working:
A two columns layout, logo left, navbar right. Now the navbar should be aligned at the bottom of the second column for bigger screens and floating to the next line directly under the logo on smaller screens.
Bigger screen:
Smaller screen:
I suppose this can be done only with JS so far, but maybe anyone knows a way to get this realized with pure CSS.
HTML:
<div class="container">
<div class="row">
<div id="col1" class="col-xs-12 col-sm-3">
<div id="logo">Logo</div>
</div>
<div id="col2" class="col-xs-12 col-sm-9">
<div id="navbar">Navbar: tab 1 | Nav tab 2 | Nav tab 3</div>
</div>
</div>
</div>
CSS:
#logo {
background-color: red; height: 100px; width: 150px; color: white;
}
#navbar {
background-color: blue; height: 30px; width: 100%; color: white;
}
I've set up a jsfiddle with the full code: http://jsfiddle.net/m4s4uqhx/6/
Any help is greatly appreciated.
set the height of col-2 similar to logo and set the navbar to position absolute and bottom 0 . replace your css with this solution
/* Latest compiled and minified CSS included as External Resource*/
/* Optional theme */
#import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
#col1 {
//border: 1px solid darkred; padding: 0px;
}
#col2 {
//border: 1px solid darkblue; padding: 0px;
}
#logo {
background-color: red; height: 100px; width: 150px; color: white; padding: 5px;
}
#navbar {
background-color: blue; height: 30px; width: 100%; color: white; padding: 5px;
}
#media only screen and (max-width : 992px){
#navbar{
position: absolute;
bottom: 0px;
}
#col2{
height: 100px;
}
}
#media only screen and (max-width : 768px){
#navbar{
position: relative;
}
#col2{
height: auto;
}
}
If the sizes of your elements are fixed as in your example, you can do the trick with padding-top, and remove it when the screen is too small (xs: <768px).
#media(min-width: 768px) {
#col2 {
padding-top:70px;
}
}
Demo on JSFiddle
Else, I guess you will have to write some JavaScript :)
If you know the exact height of you logo then you can add a padding top to the #col2 div on bigger screens using media queries
tablets and greater #media(min-width:778px){...}
desktops and greater #media(min-width:992px){...}
large screens #media(min-width:1140px){...}
Css example
#media(min-width:992px){
#col2{padding-top:70px;}
}
Working example
http://www.bootply.com/SHj7pkKt80
The issue here is that the columns are not equal height. CSS only offer a couple of options for equalising columsn heights. CSS Tables and Flexbox.
You can leave the floats in place but flexbox will override the floating to a certain extent.
Nevertheless, the impact can be minimal depending on your requirement.
Codepen Demo
#logo {
background-color: red;
height: 100px;
width: 150px;
color: white;
}
#navbar {
background-color: blue;
height: 30px;
width: 100%;
color: white;
}
.row {
display: flex;
flex-wrap: wrap;
}
#col2 {
display: flex;
align-items: flex-end;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div id="col1" class="col-xs-12 col-sm-3">
<div id="logo">Logo</div>
</div>
<div id="col2" class="col-xs-12 col-sm-9">
<div id="navbar">Navbar: tab 1 | Nav tab 2 | Nav tab 3</div>
</div>
</div>
</div>
I want to put 2 images on the same row, with size adaptation when I increase/decrease the page size, without have the image move to the other row.
Currently when my page is sized down, my second image (black block on the description) moves to the other row
Here is an screenshot of what I'm trying to do:
CSS:
.album {
margin-top: 10px;
width: 100%;
display: block;
width: auto;
height: auto;
}
.album img {
padding: 10px;
}
And my html part:
<div class="row">
<div class="album">
<img src="images/album2017.png">
<img src="images/album2016.png">
</div>
I hope you can help me,
Thanks in advance :)
You just need to use sm breakpoint FIDDLE
<div class="container">
<div class="row">
<div class="col-sm-8">
<img src="http://placehold.it/350x150">
</div>
<div class="col-sm-4">
<img src="http://placehold.it/350x150">
</div>
</div>
</div>
.album {
margin-top: 10px;
width: 100%;
display: block;
height:auto;
width:auto;
}
.album img {
padding: 10px;
width:50%;
height :auto;
}
Hope this is what you are looking for. Adjust your width % to scale according to your screen size / block size
JSFIDDLE
I hope it's should work
.album {
margin-top: 10px;
width: 100%;
display: block;
width: auto;
height: auto;
}
.album img {
width: 50%;
padding: 10px;
}
I'm trying to make an booking box with an white background over an image on my front page. So far I have managed to put an box on top with the following code:
Code:
<div class="row">
<div class="col-sm-12 contentpage">
<div class="frontimage">
<img src="~/images/index.jpg" />
<div class="col-sm-4">
<div class="bookingbox">
</div>
</div>
</div>
</div>
</div>
Css:
.bookingbox {
background-color: white;
position: absolute;
height: 100px;
margin-top: -580px;
margin-left: 10px;
}
#media (min-width: 1200px) {
.bookingbox {
display: none;
}
}
The problem now is that when you going from, lets say 1600px to 1200px the white box moves, can't make it to be static inside the image.
All my images are set with the following css the they become responsive:
img {
max-width: 100%;
}
What should I change? any ideer?
Update:
The box fitting perfectly now.. but now the image is off the aligniment with the rest of the page.
Left side is good, but right side has become bigger somehow?
The answer here, you should use z-index to do this.
.bookingbox {
background-color: red;
position: absolute;
height: 100px;
width: 100px;
z-index: 2;
position: absolute;
top: 0;
}
.frontimage {
z-index: 1;
position: absolute;
}
#media (min-width: 1200px) {
.bookingbox {
display: none;
}
}
<div class="row">
<div class="col-sm-12 contentpage">
<div class="frontimage">
<img src="https://www.wonderplugin.com/wp-content/plugins/wonderplugin-lightbox/images/demo-image0.jpg" />
<div class="col-sm-4">
<div class="bookingbox">
</div>
</div>
</div>
</div>
</div>
I'm making a homepage and it works great in my resolution, but if I try to resize the window, the different logos (divs) start to overlap each other.
This is how it's supposed to look:
But whenever I resize the window, the logos (divs/pictures) overlap.
I have a lot of code that is what I believe to be irrelevant to the problem, but just in case, this is the complete code at jsfiddle (the pictures/font doesn't work though): http://jsfiddle.net/sXy3u/
Otherwise, this is an example of code of each div that I believe you'll need to help:
<div id="youtube">
<img src="youtube.png"/>
<a href="http://www.youtube.com/">
<div id="youtubeHover">
<div id="youtubeCircle">
<div id="youtubeArrow">
</div>
</div>
</div>
</a>
</div>
That's an example of one of the tiles. Now for two of the css codes:
#youtube {
width: 195px;
height: 195px;
margin-top: 5px;
padding-top: 5px;
position: relative;
overflow: hidden;
}
And the one that's overlapping:
#yahoo {
margin-top: -810px;
margin-left: 600px;
width: 195px;
height: 195px;
position: relative;
overflow: hidden;
}
This is where you have to use the Grid System Link
It gives you responsive layout depends on your screen such as Mobile, iPad, 1024x768 or HD Wide Screen. so if you use grid system, you don't need to recode your massive CSS. just attach every Metro Style Boxes in HTML part only with almost less coding.
I guess you have no idea about Grid Systems in Web Pages. no problem. I'll give you some basic tutorial links. have a look.Link
and this one is all available Grid System in the Web Industry nowadays. just have a look.
and if you use Grid System to this concept, you will amaze :)
You need to make your own custom responsive system up for this. Here's some basic stuff you can try out:
DEM0: http://jsbin.com/AKopuGo/1/
Notice how the sizes for the smallest device, which is 240px, the boxes don't exceed 200px total, but as the page gets bigger, the boxes are sized differently. Then the floats don't take effect until a certain min-width. You will need to learn more about responsive and fluid css if you intend to make this a career. All these min-widths are guesses and the styles will need to be set up and adjusted for each min-width, but not repeated. If a class is used for all sizes, put it outside any media queries, if it's use for a certain min-width (like the sizes of the box) put it there.
.clearfix:before,
.clearfix:after {
content: " ";
display: table;
}
.clearfix:after {
clear: both
}
.page-container {
margin: 0 auto;
padding: 3%;
}
.logo-box {
width: 210px;
border: 1px solid red;
}
.logo-box > div {
float: left;
width: 100px;
height: 100px;
background: #fff;
margin-right: 5px;
margin-bottom: 5px;
}
.logo-box > div.wide {
width: 205px
}
.text {
margin-bottom: 3%
}
#media (min-width:600px) {
.logo-box {
width: 250px
}
.logo-box > div {
width: 120px;
height: 120px;
}
.logo-box > div.wide {
width: 245px
}
}
#media (min-width:800px) {
.float-left {
float: left
}
.float-right {
float: right
}
.text {
margin-left: 3%
}
.logo-box {
width: 310px
}
.logo-box > div {
width: 150px;
height: 150px;
}
.logo-box > div.wide {
width: 305px
}
}
#media (min-width:1200px) {
.logo-box {
width: 410px
}
.logo-box > div {
width: 200px;
height: 200px;
}
.logo-box > div.wide {
width: 405px
}
}
HTML
<div class="page-container">
<h1>Title</h1>
<section class="text float-right"> Date time etc. </section>
<section class="logo-box first float-left clearfix">
<div class="wide">
Reddit
</div>
<div class="square">
YouTube
</div>
<div class="square">
Google
</div>
<div class="square">
Gmail
</div>
<div class="square">
NetFlix
</div>
<div class="wide">
Pandora
</div>
</section>
<!--/.logo-box-->
<section class="logo-box second float-right clearfix">
<div class="wide">
Reddit
</div>
<div class="square">
YouTube
</div>
<div class="square">
Google
</div>
<div class="wide">
Reddit
</div>
</section>
<!--/.logo-box-->
</div>
<!--/.page-container-->
You'll also need to use fluid images.
I am having the following layout for my website and is built using responsive Bootstrap.
Now when I view it in a mobile device it comes in the following order:
HEADER
FORM
PROMOTIONS
INFORMATION
FOOTER
However, I don't want the promotions feature to come below the form for a mobile device. Instead I need the information section to come after the form and then the promotions section and then the footer.
Is there a way to achieve this using #media query?
I think, if you can control height of promotion block, this example can help you:
http://jsfiddle.net/vXb95/
<div id="header" class="bordered">header</div>
<div class="content">
<div id="form" class="bordered">form</div>
<div id="info" class="bordered">infomation</div>
<div id="promotion" class="bordered" >promotion</div>
</div>
<div id="footer" class="bordered">footer</div>
.bordered{
border:1px solid #333;
text-align: center;
min-height: 50px;
padding: 10px;
margin-bottom: 10px;
}
.content{
position:relative;
}
#form{
margin-right: 35%;
}
#promotion{
position: absolute;
right: 0;
top: 0;
width: 30%;
}
#media screen and (max-width: 400px) {
#promotion{
position: static;
width: auto;
}
#form{
margin-right: 0;
}
}
Live Demo
A dumb way to do this is by duplicating the promotional features part and showing/hiding them by media queries:
HTML
<div id="header">header</div>
<div id="form">form</div>
<div id="promotion">promotion</div>
<div id="info">info</div>
<div id="promotion2">promotion</div>
<div id="footer">footer</div>
CSS
#promotion2 { display: none; }
#media (max-width: 400px) {
#promotion { display: none; }
#promotion2 { display: block; }
}