I have a responsive layout where the sidebar drop below the content in mobile.
In full width the list of items in the sidebar are at 100% width. So its like one item in one row...
In mobile I want 2 items in 1 row... by setting the width of each item to 50%. Not sure where I am going wrong...
DEMO: http://jsfiddle.net/nN6Zt/
#item {width:100%;background:#eeefff;}
#list_item{display:block;min-height:60px;border:1px solid #333}
#media only screen and (min-width:480px) and (max-width: 768px)
{
#item {width:50%;}
h1 {font-size:180%;line-height:120%;}
}
You have given 50% width to item, give it to list-item
Working Demo : http://jsfiddle.net/surjithctly/nN6Zt/2/
#item {width:100%;
background:#eeefff;
float:left;
}
#list_item {
width: 49%;
float: left;
}
49% to avoid breakage.
Or you can use box-sizing:border-box; as Tom mentioned.
#list_item {
width: 50%;
float: left;
box-sizing:border-box;
}
You have assigned the css for div but a doesn't have any css assigned to it....since your end child element is a a tag, its more semantic to assign a styling to it for all media queries use!
amend this s to your css for #media only screen and (min-width:480px) and (max-width: 768px) {} (or whichever was required to bring in the effects)
#item > a#list_item {
display:inline-block;
width:48%; /* to avoid any clash for breaking */
}
demo
Related
This is the codepen:
https://codepen.io/GummyGod/pen/XZqbKY
That's the query i wrote:
#media screen and (max-width:500px){
.content{
display:flex;
flex-wrap:nowrap;
}
.sidebar {
order:-1;
}
.resume {
width:100%;
order:;
}
}
Basically,at the end of the css file i made a css media query in order to make it responsive at widths from 0 to 500px ,however, when the size is in that range of pixels that weird tag shows up and i can't seem to be able to style it
Try this. Remove width and float:left for sidebar,main classes. Adjust padding for space between sidebar and main class based on your need.
.sidebar, .main {
display: table-cell;
}
Not sure how to explain this but here I go:
I have 2 buttons (variable width, depending on the text inside) which are positioned next to each other (picture on top). When I make my screen smaller (picture at bottom), the buttons expand the parents width and position below each other. Is there a way to check when this happens?
I want to set a margin (so buttons don't stick to each other) and set a fixed width, ONLY when the buttons are positioned below each other, because of design reasons.
As far as I know, each browser renders a little bit different, and I also want a solution that will keep working when I decide to change the buttons text.
How would you do this? Is there a plugin or a simple jQuery script that can check this?
This is what I have so far: JSFiddle
<div class="cta-buttons-wrapper text-center">
this is button one
and button two
</div>
.cta-buttons-wrapper{ margin: 40px auto; }
.cta-buttons-wrapper .btn{ margin: 0 15px; }
.btn{
margin: auto 25px;
// ...
}
.btn-primary{
color: #fff;
background-color: lightgreen;
border-color: lightgreen;
}
.btn-primary-reversed{
color: lightgreen;
background-color: #fff;
border-color: lightgreen;
}
If you don't want to stick buttons add following css
.cta-buttons-wrapper .btn{ margin: 10px 15px; }
And for button width you need to set specific width for that using media query
#media (max-width: 767px) {
.cta-buttons-wrapper .btn
{
display:block;
width:60%;
}
}
This can be achieved without the need of a jQuery plugin, in CSS you can declare a media query for certain screen sizes and within that media query you can add different styles for the buttons that would only apply at that screen size, for example if the buttons are not displaying as you wish on mobile screen sizes you would add the below media query that would trigger at screen sizes that are 767px or less, like so:
#media (max-width: 767px) {
.cta-buttons-wrapper .btn {
display:block;
width: 100%; /* this will make the buttons span the width of the parent div */
margin: 0 0 30px 0;
}
}
I have declared width: 100%; so that the buttons span the width of the parent div on mobile only and when you add more text it will still look neat, whereas with a fixed width it does not give you that flexibility.
Here is an updated link to your fiddle with my added solution:
Fiddle
You can simply do this with CSS.
#media (max-width: 767px) {
.btn {
margin: 25px;
}
}
http://www.ontargettdesign.com
Hi,
I am having problem with the navigation bar and the logo when the webpage is resized to ipad size:
[IMG]http://i60.tinypic.com/4r95qo.png[/IMG]
How can I code it to be a narrower height, I feel I have tried everything!
Any help would be very much appreciated.
Thanks in advance
Your Media Queries are clipping the image. This is because the div you have is smaller than the background image being used. If you remove the "width" & height" the logo will display properly. To view this. Make you browser smaller to see the clipping occur (Because of #media). Right click on the logo and "inspect element". On the right or bottom it will show you the css that is applied to this image. You can toggle the css to see how the code effects your image.
either add background-size:contain; to both of the follow or remove the width and height.
#media (max-width: 979px) and (min-width: 769px)
.navbar-brand {
height: 32px;
width: 132px;
}
&
#media (max-width: 768px)
.navbar-brand {
height: 32px;
width: 132px;
}
To change make the navbar height the same across all media widths you will still have to mess with the media widths. Your standard height is "height: 76px;".
The first CSS is for the smallest possible screen
#media (max-width: 768px)
.navbar {
height: 76px; /* add this */
}
This is the second smallest screen (for tablets). You will not to get rid of the clear:both that is sending the navigation to the second line
#media (max-width: 979px) and (min-width: 769px)
.navbar-collapse {
float: none;
clear: both; /* DELETE THIS */
height: 100px; /* You can change this to 76px if you want to be consistent */
}
since the hype is Responsive Web Design, and I already know how to write it, I am just here to clarify a few questions of my own before I keep doing something wrong if I am.
If we set a divs style like so:
div {
width:200px;
height:200px;
background: #000;
margin: 10px 5px;
}
Now to be responsive the way we want would we do-
div {
background:#000
}
#media screen and(max-width:1200px) {
div {
width:300px;
height:300px;
margin: 20px 5px;//Question is here
}
}
#media screen and(max-width:720px) {
div {
width:300px;
height:300px;
margin: 20px 5px;//question is here
}
}
#media screen and(max-width:360px) {
div {
width:200px;
height:200px;
margin: 10px 5px;
}
}
The question is in face if we set the margin or any style that is going to be the same for an for greater width or minimum width do we keep assigning it do can we leave it at that? So if we set the margin at 20px 5px will that stay with it until 1200px? And the same goes for reverse will it stay the same until it gets to 360px and then change?
It's just a question that has been bothering me.
The max-width:1200px media query will apply to all sizes below, meaning that you won't need to re-apply the same values again in the 720px one.
In comparison:
#media screen and (max-width:1200px) {
/* applies to all viewports below 1201px */
}
#media screen (min-width:721px) and (max-width:1200px) {
/* only applies to viewports above 720px and below 1201px */
}
In conclusion, seeing as the values in your second (720px) media query rule is the same as the bigger one, they are applied twice (not necessary).
i think use percentage value to margin and width. You can avoid the resizing problem
I truly wouldn't be posting a question if I hadn't already spent hours digging through files and researching. I must really not know what I'm looking for :-|
I want to know how and why divs in a container (or the container itself) can change to 100% width when a responsive design is scaled to iphone dimensions - like the below:
http://demo2.woothemes.com/whitelight/about/
the sidebar sits underneath the main content, then the divs inside stretch to 100%
It's driving me absolutely mad! Any help / direction must appreciated :)
Basic Media query responsive layout example:
Demo: http://jsbin.com/ayojan/1/edit
Resize browser to see effect.
div {
outline:solid black;
}
.content {
width:80%;
float:left;
}
.sidebar {
width:20%;
float:left;
}
#media only screen and (max-width: 767px) {
.sidebar {
width:100%;
float:none;
}
.content {
width:100%;
float:none;
}
}
Key points: inside the media query you unfloat the elements (float:none) and set them to width: 100%;