My div is going down when rezise - html

i'm starting with responsive design and i'm having the next issue:
when i rezise my div, in a design of two column and the right one is going down.
Ex before rezise:
and after rezise:
I dont jnow why is going down f the design is in %. Maybe somebody can help'me, here the css code that i'm using.
* { margin: 0px; padding: 0px; }
h1 {font: bold 20px verdana, sans-serif; }
h2 {font: bold 14px verdana, sans-serif; }
header, section, footer, aside, nav, article, figure, figcaption, hgroup { display: block; }
body { width: 100%; text-align: center; }
#envoltura { margin: 15px auto; text-align: left; padding: 0px 2% 0px 2%}
#cabecera { background: #FFFBB9; border: 1px solid #999999; padding: 20px; text-align: center; }
#menu { background: #CCCCCC; padding: 5px 15px; text-align: center; }
#menu li { display: inline-block; list-style: none; padding: 5px; font: bold 14px verdana, sans-serif; }
#seccion { float: left; width: 65%; margin: 20px 0px 0px 0px; border: 2px solid #999999; padding: 2%; text-align: center; }
#lateral { float: left; width: 26.4%; margin: 20px 0px 0px 0px; padding: 2%; background: #CCCCCC; border: 2px solid #999999; text-align: center; }
#pie { clear: both; text-align: center; padding: 20px; border-top: 2px solid #999999; }

Because you haven't allowed enough room for the two columns at that window size!
► Declare different layout per media queries:
(method below based on a min and max screen resolution range)
#media only screen and (min-width: 480px) and (max-width: 979px) {
/* Your styles for between these two resolutions here */
}
OR! depending on what you want to do, complete end goal, you may not even need to use media queries
► Define width of each columns in a percentage relevant to either the browser, or a wrapper div.
#wrapper {
position: relative; // the below is relative to this
margin: 0 auto; // center
max-width: 1024px; // max size of container
width: 100%; // 100% between min and max ;)
min-width: 960px; // lowest toggle point
}
.left {
width: 80%; // 80% of above
float:left;
min-width: 500px; // add a min-width to declare stopping point
}
.right {
width: 20%; // 20% of above
float:right;
min-width: 100px; // add a min-width to declare stopping point
}

It is because your divs are equaling more than 100% of your parent try this and edit it as you see fit
If you post your html I can explain it furthur
set your body to an absolute value example body{width:1200px} then set your first media query to #media screen and (max-width: 1199px){body{width: 100%}} This way you know that anything over 1199px the page will break

Related

Why does .post edit the max-width of my footer?

I am new to HTML and CSS so I am doing a online course, I don't understand what went wrong here and I cannot find it in my course.
My footer is smaller then it used to, it was as big as my header and I want it as big as my header. When I added all the .post code, it went wrong. When I edit my .post max-width my footer width is also adjusted. Please help me :)
.container {
max-width: 1000px;
margin: 0 auto;
}
#footer {
background-color: #2f2f2f;
padding: 50px 0;
}
.column {
min-width: 300px;
display: inline-block;
vertical-align: top;
}
#footer h4 {
color: white;
text-transform: uppercase;
letter-spacing: 0.1em
}
#footer p {
color: white;
.post {
max-width: 1000px;
margin: 0 auto;
padding: 60px 0;

float:none; not working with media queries

I'm following a tutorial about responsive design and when trying to set the float property to none for a media query targeting (max-width: 625px) for a section having a class main as in the following rule-sets :
/* Section main */
section.main {
background-color: blue;
width: :100%;
float: none;
text-align: left;
}
section.main aside div.content {
background-color: green;
margin: 8px 20px 8px 0;
padding: 5px 0px 10px 85px;
background-size: 50px 50px;
background-position: 20px 5px;
}
Here is the full html and css code all together: jsfiddle (I added colors of blue to the section.main and the green color to the section.main aside div.content in these same media query rule-sets to make sure they do have effect on the html and to make it easy to be located in the page.
These three green divs are supposed to be stacked vertically when the float is set to none.
here: JSfiddle i've edited your fiddle and came up with this. hope this sample helps.
section.main aside {
float: none;
display: block;
width: 100%;
}
section.main aside div.content {
background-color: green;
margin: 8px 20px 8px 20px;
padding:20px 15px;
text-align: center;
background-size: 50px 50px;
background-position: 20px 5px;
}

How to apply media query?

I have created a site using HTML and CSS. The site is currently not responsive and I need to change into a responsive one. I have used media queries but it doesn't seem to be working. Are there any mistakes in my code? I have applied media queries to the entire CSS. Should I apply media query to the entire CSS or only a particular part of the CSS?
I tried using the media query #media screen and (max-width: 300px) { } and it works when resizing the browser but after that when the browser is maximized again the desktop style is not getting applied.
#media screen and (max-width: 300px) {
body {
font: 100% Verdana, Arial, Helvetica, sans-serif;
background: #fff;
margin: 0;
/* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
padding: 0;
text-align: center;
}
.thrColElsHdr #container {
width: 800px;
background: #FFFFFF;
margin: 0 auto;
/* the auto margins (in conjunction with a width) center the page */
border: 1px solid #000000;
text-align: left;
/* this overrides the text-align:
center on the body element. */
margin-bottom: 0px;
}
.thrColElsHdr #header {
background: #DDDDDD;
padding: 0 10px;
/* this padding matches the left alignment of the elements in the divs that appear beneath it. If an image is used in the #header instead
of text, you may want to remove the padding. */
background-image: url(images/top.png);
height: 160px;
}
#top_menu {
color: #e5e491;
font-size: 15px;
text-decoration: none;
height: -20px;
width: auto;
float: right;
margin: 90px 0 -50px 0;
}
#top_login {
color: #e5e491;
font-size: 10px;
text-decoration: none;
float: right;
text-align: right;
margin: 0px 0 0px 0;
width: 600px;
height: 30px;
position: relative;
top: -160px;
}
.thrColElsHdr #header h1 {
margin: 0;
/* zeroing the margin of the last element in
the #header div will avoid margin collapse - an unexplainable space between divs. If the div has a border around it, this is not necessary as that also avoids the margin collapse */
padding: 0px 0;
/* using padding instead of margin will allow you to
keep the element away from the edges of the div */
color: #FFF;
font-family: "Times New Roman", Times, serif;
height: 160px;
}
.thrColElsHdr #sidebar1 {
float: left;
width: 16em;
/* since this element is floated, a width must be given */
background: #75b808;
/* top and bottom padding create visual space within this div */
margin: 15px 10px 15px 15px;
background-image: url(images/news_top.png);
background-repeat: no-repeat;
padding: 15px 2px 2px 2px;
font-size: 10px;
}
.thrColElsHdr #sidebar2 {
float: right;
width: 17em;
/* since this element is floated, a width must be given */
background: #EBEBEB;
/* the background color will be displayed for the length of the content in the column, but no further */
padding: 10px 0;
/* top and bottom padding create visual
space within this div */
border: #0a4b67;
border-width: thick;
margin: 5px;
font-size: 10px;
}
.thrColElsHdr #sidebar1 h3,
.thrColElsHdr #sidebar1 p,
.thrColElsHdr #sidebar2 p,
.thrColElsHdr #sidebar2 h3 {
margin-left: 10px;
/* the left and right margin
should be given to every element that will be placed in the side columns */
margin-right: 10px;
}
.thrColElsHdr #mainContent {
margin: 0 12em 0 1em;
/* the right margin can be given in ems or pixels. It creates the space down the right side of the page.
*/
color: #0a4b67;
}
.thrColElsHdr #mainContent h2 h3 h4 {
color: #0a4b67;
}
.thrColElsHdr #footer {
padding: 0 10px;
/* this padding matches the left alignment of the elements in the divs that appear above it. */
background: #E1E994;
}
.thrColElsHdr #line {
padding: 0 10px;
/* this padding matches the left alignment of the elements in the divs that appear above it. */
background: #E1E994;
margin-top: 0px;
}
.thrColElsHdr #footer p {
margin: 0;
/* zeroing the margins of the first element in the footer will
avoid the possibility of margin collapse - a space between divs */
padding: 10px 0;
/* padding on this element will create space, just as the the margin would have, without the margin collapse issue */
}
/* Miscellaneous classes for reuse */
.fltrt {
/* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */
float: right;
margin-left: 8px;
}
.fltlft {
/* this class can be used to float an element left in your
page */
float: left;
margin-right: 8px;
}
.clearfloat {
/* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain a float */
clear: both;
height: 0;
font-size: 1px;
line-height: 0px;
}
.thrColElsHdr #container #header #top_menu_logo {
margin-top: 0em;
margin-right: 0em;
margin-bottom: 0em;
margin-left: 0em;
float: left;
}
.thrColElsHdr #container #header #top_menu a {
color: #e5e491;
}
.thrColElsHdr #container #subheading {
font-size: 14px;
height: 211px;
}
div#nifty {
font-size: 12px;
background: #2d6482;
width: 300px;
}
div.rounded div {
height: 1px;
overflow: hidden;
}
#radiusx,
#radiusy {
text-align: right;
width: 20px;
}
div#nifty p {
color: #dfe791;
padding: 2px;
margin: 2px;
}
#thetext {
float: right;
width: 380px;
padding: 10px;
font-size: 12px;
font-weight: bold;
}
#theimg {
float: left;
width: 400px;
}
}
</style>
please any idea any mistake please comment my question ?
The way to do media queries is this:
/* rules that apply regardless of resolution */
.some > .css > .selector {
display: block;
background-color: rgb(255, 255, 255);
}
#media screen and (min-width: 1440px) {
/* rules that apply for screens >= 1440px */
.some > .css > .selector {
width: 1280px;
color: rgb(144, 144, 144);
}
}
#media screen and (min-width: 1024px) and (max-width: 1439px) {
/* rules that apply for screens 1024px - 1439px */
.some > .css > .selector {
width: 920px;
color: rgb(102, 102, 102);
}
}
#media screen and (min-width: 640px) and (max-width: 1023px) {
/* rules that apply for screens 640px - 1023px */
.some > .css > .selector {
width: 500px;
color: rgb(64, 64, 64);
}
}
#media screen and (max-width: 639px) {
/* rules that apply for screens 639px and below */
.some > .css > .selector {
width: 300px;
color: rgb(0, 0, 0);
}
}
Alter the conditions with your desired breakpoints, of course.
As a guideline, always apply your media queries after your style for that element / logical section of elements. This makes it convenient later on to find and edit your styles for a particular element across all resolutions.
A few things to note for first-timers:
ensure that you use px values that don't overlap in the media queries.
the rules within media queries will "overwrite" those outside of it.
You should do a link tag for the css and have this meta tag
and your
#media screen and (max-width: 300px) {}
does not make sense because then you will choose a screen that's smaller than 300px width
#media screen and (min-width: 300px) and (max-width: 460px) {}
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>

How to horizontally centre floated text

if you go and reduce the width of the window to view the screen as if it were a mobile device you can see that the orange "badges" may not be entered (especially when only one badge fits per line) I want it to fit more badges in if possible whilst always keeping the badge, or group of badges on that line entered horizontally. The class is badge that isn't being centered Thank you in advance!! :)
jsfiddle: http://jsfiddle.net/avg24wrk/
This is the HTML
<div class="container">
<div class="sidebar">
<div class="sidebar-inner">
<p class="badge"><span class="vertical-align">Book a Free Consultation!</span></p>
<p class="badge"><span class="vertical-align">Second Point</span></p>
<p class="badge"><span class="vertical-align">Third Point</span></p>
</div>
</div>
and this is the CSS
* {
border: 0;
margin: 0;
padding: 0;
}
.sidebar {
float: left;
width: 25%;
color: #505050;
}
.sidebar-inner {
margin: 0 30px 0 35px;
}
.badge {
margin: 10px auto;
font-size: 24px;
text-align: center;
border-radius: 7px;
padding: 20px 20px;
background-color: #ed9727;
cursor: pointer;
}
#media screen and (max-width: 490px) {
.sidebar {
width: 100%;
}
.sidebar-inner {
padding-bottom: 20px;
border-bottom: 2px solid #505050;
margin: 0 30px;
overflow: hidden;
}
.badge {
float: left;
margin: 15px 10px;
max-width: 150px;
min-height: 50px;
display: table;
}
}
have you tried adding text-align: center; to class you want to center
since i you didn't mention which class you want to center so i will give you a simple rule try this
please mention class you want to center

My button's text is not resizing?

My button has following CSS code. When I resize the window the text falls outside of the div in chrome. (usng the mobile layout)
http://www.syntra-limburg.be/voltijds-praktijkleren
a.syntra-green-button {
background-color: #6faf3c;
border: 1px solid #9dcc77;
color: white;
padding: 15px 2%;
margin: 5px auto 0px;
position: relative;
font-size: 1.35em;
width: 190px;
max-width: 100%;
text-align: center;
display: block;
}
I fixed it using following code but I was wondering if there isn't a more elegant solution? I do not understand why this is happening.
.responsive-layout-mobile a.syntra-green-button {
font-size: 1em;
}
Try font-size percent like font-size: 115%;
css
a.syntra-green-button {
background-color: #6faf3c;
border: 1px solid #9dcc77;
color: white;
padding: 15px 2%;
margin: 5px auto 0px;
position: relative;
font-size: 115%;
width: 190px;
text-align: center;
display: block;
}
Set width to auto. You limited it cause of that it overflows
You can change how the width of the button is rendered using the below. First change the width to be percent based for desktop style displays:
width: 30%;
but also add a minimum width for when it it resized for a responsive device that fits the entire word:
min-width: 200px;
So full class would be:
a.syntra-green-button {
background-color: #6faf3c;
border: 1px solid #9dcc77;
color: white;
padding: 15px 2%;
margin: 5px auto 0px;
position: relative;
font-size: 1.35em;
width: 200px;
min-width: 30%;
max-width: 100%;
text-align: center;
display: block;
}
See this JSFiddle: http://jsfiddle.net/8tBQ3/
.responsive-layout-mobile a.syntra-green-button {
font-size: 100%;
}