Hello, I am making a website and I can't center my div on a my main computer's screen without it messing up on my smaller laptop. I am using percentages but that doesn't seem to be helping I will attach 2 different pictures and my css. Thank you in advance.
Laptop
Pc
CSS
body {
background-color: black;
}
.box {
position: absolute;
border-radius: 5%;
width: 8%;
height: 4%;
margin: 5%;
background-color: #888888;
border-style: solid;
border-width: medium;
border-color: orange;
}
.Forum-Block {
position: absolute;
border-radius: 5%;
left: 10%;
top: 0%;
width: 70%;
height: 140%;
margin: 5%;
background-color: #888888;
border-style: solid;
border-width: medium;
border-color: orange;
}
.Top-Bar {
position: absolute;
height: 30px;
width: 60%;
top: 8%;
left: 10%;
}
.Back-Box {
float: right;
padding: 3%;
color: white;
background-color: black;
}
.FriendsB-Box {
float: right;
padding: 3%;
color: white;
background-color: black;
}
.RequestsB-Box {
float: right;
padding: 3%;
color: white;
background-color: black;
}
.SentRequestsB-Box {
float: right;
padding: 3%;
color: white;
background-color: black;
}
.SendRequestB-Box {
float: right;
padding: 3%;
color: white;
background-color: black;
}
.PendingRequestsB-Box {
float: right;
padding: 3%;
color: white;
background-color: black;
}
.Back-Box:hover {
background-color: #262626;
}
.FriendsB-Box:hover {
background-color: #262626;
}
.RequestsB-Box:hover {
background-color: #262626;
}
.SentRequestsB-Box:hover {
background-color: #262626;
}
.SendRequestB-Box:hover {
background-color: #262626;
}
.PendingRequestsB-Box:hover {
background-color: #262626;
}
You need create one css this genre to achieve differentiate the 16 inches laptop for a 10 per example.
#media screen and (min-width: 900px) {
body {
background-color: lightgreen;
}
}
#media screen and (max-width: 901px) {
body {
background-color: blue;
}
}
u cannot center the div if it's in position, because it change position of the div according to the screen size.
Add Html code with ur question is better to solve the problem.
I have problem aligning three boxes to the center of section.
Here is what I have so far:
/*==============Custome Css ====================*/
.slider_patch {
background: rgba(63, 61, 61, 0.61);
padding: 0px 15px;
box-shadow: 1px 1px 28px #2F2F2F;
}
button.small.skyblue a {
color: #fff;
}
/*==============Custome Css ====================*/
/* #Misc
================================================== */
/* EXTRAS */
.brdr-r1, .brdr-r2 { border-right: 1px solid #e5e5e5; padding-right: 19px; }
.brdr-l1, .brdr-l2 { border-left: 1px solid #e5e5e5; padding-left: 19px; }
.brdr-r2 { padding-right: 27px; }
.brdr-l2 { padding-left: 27px; }
.pad-r27 { padding-right: 27px; }
.pad-l27 { padding-left: 27px; }
.alignright { text-align: right; }
img.alignright { float: right; }
.alignleft { text-align: left; }
img.alignleft { float: left; }
.aligncenter { text-align: center; }
.wp-caption { display: block; color: #444; }
.wp-caption-text { font-size: 15px; }
.sticky { color: #555; }
.gallery-caption { display: inline; }
.bypostauthor { font-size: 13px; }
.moonicons-box1 { font-size: 16px; display: inline-block; width: 15em; padding: .25em .5em; background: #fff; margin: .5em 1em .5em 0; border: 1px solid #e8e8e8; }
.alignright { text-align: right; }
img.alignright { float: right; }
.alignleft { text-align: left; }
img.alignleft { float: left; }
.aligncenter { text-align: center; }
.wp-caption { display: block; color: #444; }
.wp-caption-text { font-size: 15px; }
.sticky { color: #555; }
.gallery-caption { display: inline; }
.bypostauthor { font-size: 13px; }
/* Scroll to top */
#scroll-top a { width: 16px; height: 16px; padding: 6px 8px 9px; border-radius: 4px; background: #818c90; position: fixed; bottom: 48px; right: 32px; display: none; opacity: 0.89; filter: alpha(opacity=89); z-index: 499841; }
#scroll-top a i { font-size: 16px; color: #fff; display:block; }
#scroll-top a:hover { background-color: #ffcc00; cursor: pointer; }
h1.pnf404 { font-size: 176px; line-height: 1.1; font-weight:900;}
h2.pnf404 { font-size: 42px; line-height: 1.2; font-weight:700; }
input.txbx404 { float:left; margin-top:2px; margin-right:4px; padding:7px 4px; min-height:inherit; border-radius:3px; }
input.btn404 { float:left; margin:1px; padding:8px 12px 9px; }
.v-shadow-l { background:url(../images/v-shadow-left.png) no-repeat right center; }
.v-shadow-r { background:url(../images/v-shadow-right.png) no-repeat left center; }
.v-shadow-r, .v-shadow-l { min-height:320px; }
.pad-r10 { padding-right:10px; }
.pad-r20 { padding-right:20px; }
.pad-r30 { padding-right:30px; }
.pad-r40 { padding-right:40px; }
.pad-l10 { padding-left:10px; }
.pad-l20 { padding-left:20px; }
.pad-l30 { padding-left:30px; }
.pad-l40 { padding-left:40px; }
/* #Column Shortcodes
----------- */
.one_half, .one_third, .two_third, .three_fourth, .one_fourth, .one_fifth, .two_fifth { margin-right: 3%; float: left; margin-bottom:2px; }
.one_half { width: 48%; }
.one_third { width: 30.6666%; }
.two_third { width: 65.3332%; }
.one_fourth { width: 22%; }
.three_fourth { width: 74%; }
.one_fifth { width: 16.8%; }
.two_fifth { width: 37.6%; }
.column-last { margin-right: 0 !important; clear: right; }
.easyPieChart { position: relative; text-align: center; }
.easyPieChart canvas { position: absolute; top: 0; left: 0; }
.pie { text-align:center; font-size:49px; position:relative; margin:0 auto 20px; }
.pie p { font-size:16px; color:#888; font-weight:400; position:absolute; bottom:-52px; width:100%; padding-top:10px; border-top:2px solid #f9f9f9;}
.container .pie p { margin-bottom:0;}
/* #Media Queries
================================================== */
/* Smaller than standard 960 (devices and browsers) */
#media only screen and (max-width: 959px) {
.img-box { width: 256px; height: 188px; }
.last-project .img-box { background: #EA3C3C; }
.last-project .img-box:nth-child(even) { background: #F66060; }
.ab-box { height: 235px; }
.author-detail { width: 218px; }
.comment-contents { width: 343px; }
.child-comment .comment-contents { width: 263px; }
.contact input { width: 330px; float: none; }
.contact textarea { width: 486px; }
.row.magic, .s-qoute-man { padding: 0; margin-bottom: 10px; }
a.get { margin-bottom: 14px; }
.pad-r10, .pad-r20, .pad-r30, .pad-r40 { padding-right: 5px; }
.pad-l10, .pad-l20, .pad-l30, .pad-l40 { padding-left: 5px; }
#main-content-pin .container { width: auto; }
}
/* Tablet Portrait size to standard 960 (devices and browsers) */
#media only screen and (min-width: 768px) and (max-width: 959px) {
#boxed-wrap { width: 828px; }
.social-icons a { margin: 1px 4px 0 4px; }
.row.magic { padding-left: 20px; margin-bottom: 10px; }
#tline-content { width: 800px; }
.tline-box { width: 335px; }
/*#nav a span, #nav a:after { font-size:9px; }*/
.blog-date-sec { width: 42px; height: 42px; }
.help-box { width: 50%; }
}
/* All Mobile Sizes (devices and browser) */
#media only screen and (max-width: 767px) {
.sidebar, .rgt-cntt, .sidebar.leftside { padding-right:0; background:none; padding-top:40px; margin-top:40px; border-top:5px solid #e5e5e5;}
.rgt-cntt, .sidebar.leftside { padding-top:0px; margin-top:0px; border-top:0 none;}
.contact-form .txbx { width:224px;}
.pricing-table .plans-f-list.respo { display:inline; visibility:visible;}
#header.super-fixed { height:auto; box-shadow:none; border-bottom:4px solid #f0f0f0;}
#headline { height:auto; border-bottom:3px solid #f3f3f3; padding:14px 0; }
#headline h3 { border-top-color:#f6f6f6; font-size:37px; text-align:center;}
#headline h3 small { display:block; margin-top:14px; margin-bottom:0; font-size:16px; letter-spacing:0; font-weight:400; }
.servobx, .servobx div, .servobx img, ul#main-ibox li, ul#main-ibox li.active9 { width:100%; float:none;}
#search-form { display:none; }
#header .alignright, top-inf.alignright { text-align:center;}
#search-form2 { display:block; }
#side-content { padding-bottom:30px; border-bottom:5px solid #f3f3f3; margin-bottom:40px;}
.top-bar { height:65px; padding:5px 0 6px; background:url(../images/topsobg1.png) repeat-x center center; white-space:nowrap; overflow:hidden;}
.top-bar h6 { font-size:11px; letter-spacing:0; margin:0 10px 0 0;}
.top-bar h6 i { font-size:12px; width: 12px; height: 12px; text-align: center; padding:3px; margin-right:3px; }
.top-bar .socailfollow, .top-links, .top-links.rgtflot, .top-bar .socailfollow.lftflot { float:none; text-align:center; clear:both; min-height:22px;}
.top-bar .socailfollow, .top-bar .socailfollow.lftflot { padding-top:8px;}
.top-bar .socailfollow a, .top-bar .socailfollow.lftflot a, .top-links p, .top-links img { float:none; display:inline; padding-top:10px; background:none;}
.top-links, .top-links.rgtflot { margin:0 0 8px 0; padding-top:4px; }
.top-links.rgtflot { margin-top:12px; margin-bottom:6px;}
.container hr { margin-left:0; margin-right:0;}
.blog-date-sec { border:0 none; margin:0; text-align:left; border-bottom:1px solid #e5e5e5; background:#fdfdfd;}
.blog-post { border-bottom-width:3px;}
.nav-search { float: none; margin: 0; }
.img-box { width: 420px; height: 308px; }
.comment-contents { width: 328px; margin-right: 0; }
.child-comment .comment-contents { width: 248px; }
.contact textarea { width: 398px; }
.author-detail { margin: 20px 0; }
.blog-date-sec { width: auto; display:block; -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; border: none; border-bottom: 2px solid #e3e3e3; margin-bottom: 5px; }
.blog-date-sec span, .blog-date-sec h3 { display: inline; margin: 0 10px; line-height: 50px; }
.blog-date-sec span { font-size: 20px; font-weight: 300; }
.blog-date-sec h3 { font-size: 32px;}
.contact-form .txbx { width: 224px; }
.pricing-table .plans-f-list.respo { display: inline; visibility: visible; }
#headline h3 { border-top-color: #f6f6f6; }
.image-gallery ul li, .image-gallery ul li img { display:block; width:auto; max-width:100%; height:auto; float:none;}
input[type="text"].header-saerch, input[type="text"].header-saerch:focus { width: 261px; margin-top: 10px; }
.logo { text-align: center; }
.pin-box { width: 256px; }
.tline-box .blog-date-sp { width: 80%; }
.tline-box .blog-com-sp { width: 0; display: none; }
.tabs-left > .nav-tabs, .tabs-left > .nav-tabs > li > a, .nav-tabs > li, .nav-tabs > li.active, .tabs-left > .nav-tabs > li.active > a, .tabs-left > .nav-tabs .active > a:hover { width:100%; display:block; padding-left:0; padding-right:0; }
.tabs-left > .nav-tabs > li > a { border-right:0 none;}
.tabs-left > .tab-content { border:0 none;}
.tab-content .columns, .tab-content .column { margin:0 10px; max-width:90%; }
.date-sp-wrap { margin: 0; float: right; margin-bottom: 7px; }
.blog-line .blog-date-sec { height: auto; }
.v-shadow-r, .v-shadow-l { min-height: inherit; background: none; }
.pad-r10, .pad-r20, .pad-r30, .pad-r40, .pad-l10, .pad-l20, .pad-l30, .pad-l40 { padding: 0; }
.one_half, .one_third, .two_third, .three_fourth, .one_fourth, .one_fifth, .two_fifth { width: 100%; float: none; margin-right: 0; }
.latest-f-blog, .qot-week { margin:0;}
.callout { margin:10px 0px 20px; }
.brdr-l1, brdr-r1 { padding:0; border:0 none; }
.brdr-l1 { margin-top:30px;}
.tab-content p, .tab-content li { font-size: 12px; }
.help-box { width: 100%; }
.ab-box { height: auto; padding-bottom: 25px; }
input[type="text"].header-saerch, input[type="text"].header-saerch:focus { float: none; display: inline; position: relative; z-index: 10000; }
.jcarousel-next, .jcarousel-prev { padding:12px; }
.jcarousel-prev { right:38px;}
.jcarousel-next:after, .jcarousel-prev:after { top:13px; right:13px;}
.our-clients-wrap .jcarousel-next, .our-clients-wrap .jcarousel-prev { padding:10px;}
.is-sticky, .is-sticky #header { position:relative; height:auto;}
.is-sticky #header { margin-top:0;}
.is-sticky .logo { height:auto; margin-top:0; }
.is-sticky .logo img { max-height:auto; height:auto; }
}
/* Mobile Landscape Size to Tablet Portrait (devices and browsers) */
#media only screen and (min-width: 480px) and (max-width: 767px) {
.help-block { height: auto; }
#boxed-wrap { width: 460px; }
.page-subtitle { left: 0; padding: 10px 0 0 20px; bottom: 0; border-bottom: 1px solid #e8edee; margin-bottom: 20px; height: auto; width: auto; clear: both; background: #fdfdfd; border-radius: 0; }
.contact-form .txbx { width: 338px; }
.pricing-table .plans-f-list.respo { display: inline; visibility: visible; }
.jcarousel-item, .last-project .portfolio-item { max-width: 210px; height: 157px; float: left; }
.pin-box { width: 166px; width: 164px\9; }
#tline-content { width: 460px; }
.tline-box { width: 165px; }
}
/* Mobile Portrait Size to Mobile Landscape Size (devices and browsers) */
#media only screen and (max-width: 479px) {
.nav-wrap2.mn4 #nav a { padding: 15px 4px; }
#menu a { padding: 15px 4px; }
.img-box { width: 300px; height: 220px; }
.author-detail { width: 254px; }
.author-arrow { width: 11px; height: 6px; background: url('../images/testimonial-arrow-top.png') no-repeat; left: 25px; top: -6px; }
.contact input { width: 288px; margin-right: 0; }
.contact textarea { width: 278px; }
#boxed-wrap { width: 340px; }
.footbot { min-height: 38px; height: auto; }
.page-subtitle { left: 0; padding: 10px 0 0 20px; bottom: 0; border-bottom: 1px solid #e8edee; margin-bottom: 20px; height: auto; width: auto; clear: both; background: #fdfdfd; border-radius: 0; }
.pricing-table .plans-f-list.respo { display: inline; visibility: visible; }
.pricing-table ul { width: 136px; }
.pricing-table ul li { width: 124px; padding: 5px; }
.pricing-table ul li.plan-header, .pricing-table ul li .plan-title, .pricing-table ul li .plan-price { max-width: 136px; }
.pricing-table ul li.plan-footer { max-width: 114px; }
.portfolio-item { margin-bottom: 14px; }
.commentin { width: 92%; }
#tline-content { width: 300px; }
.tline-box { width: 250px; }
.tline-row-l, .tline-row-r { display: none }
.tline-box.rgtline { float: left; left: 0; }
}
#media only screen and (min-width: 1200px) {
#boxed-wrap { width:1180px;}
.white-space { height:110px;}
h4.subtitle { margin:39px 0 21px 0; }
#main-content-pin .container { padding:0 40px; }
.sidebar.leftside { background-position: 295px; padding-right:70px; }
.blog-date-sec h3 { font-size:36px;}
}
#media screen and (min-width: 767px) {
/* ensure #nav is visible on desktop version */
#nav { display: block !important; }
.ls-layer h1, .ls-layer h3 { left:10px;}
}
button.small.skyblue.demooo {
width: 65%;
/*border-bottom: 6px solid rgb(0, 150, 192);*/
}
li.color {
background-color: rgb(197, 197, 197);
padding: 4px;
}
section.container.first-block.aligncenter.colorbar {
/*background: rgb(0, 173, 239);*/
/* width: 100%; */
/* left: 10px; */
padding: 0px 38px 0px 38px;
}
h4.slight.frontsight {
color: #333;
}
figure.shop-item.one_fourth.boxwrap {
background: white;
margin-bottom:35px;
border-radius: 4px;
box-shadow: 0px 1px 6px rgba(0, 0, 0, 0.42);
/*margin-right:10px;
width: 17%;*/
/* padding: 6px; */
/* left: 99px; */
/* color: black; */
/* padding: 0px; */
/* top: 18px; */
}
h4.fronttext {
font-size: 15px;
line-height: 24px;
/* color: black !important; */
}
figure.shop-item.one_fourth.boxwrap:hover {
background: rgba(239, 239, 239, 1);
/* color: white; */
}
/* --------Custom CSS-------------*/
table {
width:100%;
}
table tr{
height:20px;
}
table tr td p{
margin-bottom:0px;
}
tr:nth-child(even) {
background-color: rgb(166, 206, 244);
}
tr:nth-child(odd) {
background-color: rgb(207, 230, 252);
}
tr:nth-child(even):hover {
background-color: rgb(242, 244, 245);
}
tr:nth-child(odd):hover {
background-color: rgb(242, 244, 245);
}
td:nth-child(even) {
vertical-align:middle;
text-align:left;
padding:10px;
}
td:nth-child(odd) {
vertical-align:middle;
text-align:left;
padding:10px;
}
.parallax-sec .blox{
padding:20px 0 0px;
}
.eleven.columns .shop-wrap figure{
margin-right: 3%;
}
table.product-details caption{
float:left;
}
.product-details{
width:100%;
}
.contact-inf p{
margin-bottom:10px;
}
.response{
height:600px;
width:80%;
margin:0 auto;
display:block;
padding:60px 50px;
text-align:center;
font-size:14;
}
.ls-layer h2{
font-size:40px !important;
}
/*---------Custom CSS--------------*/
<section class="container first-block aligncenter colorbar">
<hr class="vertical-space3">
<h2 class="mex-title">Welcome to the Polymers Enterprises</h2>
<h4 class="slight frontsight">Scaling new heights on the strength of Excellence, Efficiency & Ethics</h4>
<hr class="vertical-space3">
<div class="services">
<div class="one_fourth">
<article class="icon-box1"><i class="fa-user"></i>
<h5>ABOUT US</h5>
<p>For over 30 years, Polymers Enterprises has developed a record of service, growth and reliability unsurpassed....</p>
<button type="button" class="small skyblue demooo" onclick="window.location.href='about.html'">Read more</button>
</article>
</div>
<!--<div class="one_fourth">
<article class="icon-box1"><i class="li_bulb"></i>
<h5>EFFICIENCY</h5>
<p>We have made good relationship with customers by supplying them excellent quality products, which help us to ...</p>
<button type="button" class="small skyblue demooo" onclick="window.location.href='about.html'">Read more</button>
</article>
</div>-->
<div class="one_fourth">
<article class="icon-box1"><i class="li_note"></i>
<h5>WHAT WE DO</h5>
<p>Our policy is to achieve Quality in supply chain and maximize the serviceability to the client coupled with quality of cost....</p>
<button type="button" class="small skyblue demooo" onclick="window.location.href='about.html'">Read more</button>
</article>
</div>
<div class="one_fourth column-last">
<article class="icon-box1"><i class="fa-cubes"></i>
<h5>OUR PRODUCTS</h5>
<p>Polymer Enterprises provides a wide range of products and consulting services to customers .....</p>
<button type="button" class="small skyblue demooo" onclick="window.location.href='our_products.html'">Read more</button>
</article>
</div>
</div>
</section>
I have tried giving width display:block, display:inline-block and margin: 0 auto but no luck.Also I have been to almost all questions here but noone helped me. Can anyone help me get it sorted?
Here is Fiddle
Thanks !
Making them display: inline-block does work, you just need to remove the float.
.one_half, .one_third, .two_third, .three_fourth, .one_fourth, .one_fifth, .two_fifth {
margin-right: 3%;
display: inline-block; /* remove float and add display inline-block */
margin-bottom:2px;
}
Demo
Note: Add vertical-align:top; if you want the content in each to line up, demo here.
I've looked everywhere for a reasonable answer to this, but I can't find it. I have a relatively simple responsive website and it works fine on every screen, except for below 768px. For some reason, the body gets stretched and I get some horizontal scrolling, despite everything being set to 100%. The body is the only portion that appears to be wider than the viewport. I have a typical reset stylesheet to clear all padding and margins. I didn't forget to set meta name="viewport" tags or initial-scale. I honestly have no idea what is going on. The layout is fine on a tablet. It is even correct if I turn my phone to landscape. It's only in portrait that the body gets stretched about 15px outside the viewport and I have some horizontal scrolling. There is just blank white space on the right. You can check out the link on your phone to see the issue firsthand. Any ideas on how to fix this?
The layout is pretty simple
<body>
<div data-ng-include="'app/layout/shell.html'">
</div>
</body>
Here's the shell
<header class="fixed-header-shell" data-ng-include="'app/layout/topnav.html'"></header>
<div class="sections-shell" data-ng-view></div>
<footer class="footer-shell" data-ng-include="'app/layout/footer.html'"></footer>
All of the shell's are set to 100% width and have no right or left padding. Here is the entire page css for reference.
#import "colors";
#import "fonts";
#import "reset";
#import "init";
/***********************
Variables
************************/
/*Header*/
#defaultHeaderHeight: 110px;
#defaultNavHeight: 50px;
#defaultHeaderPadding: #defaultHeaderHeight/2 - #defaultNavHeight/2;
#defaultHeaderSidePadding: 5.0%;
/*Footer*/
#defaultFooterHeight: 70px;
/*Section*/
#defaultSectionPadding: 60px;
//#defaultSidePadding: 5.0%;
#defaultSidePadding: 0px;
#defaultSectionHeaderMargin: 35px;
#mediumSidePadding: 2.5%;
#smallSidePadding: 1.5%;
#sectionShellWidth: 100%;
#defaultSectionWidth: 55%;
/***********************
Mixins
************************/
.Clickable
{
&:hover
{
text-decoration:none;
cursor: pointer;
color: #primaryAccent;
}
&:visited
{
text-decoration:none;
}
&:active
{
text-decoration:none;
}
&:link
{
text-decoration:none;
}
}
.Button
{
padding: 8px;
background-color: #divider;
color: #primaryDark;
border-style: solid;
border-radius: 3px;
}
.Image(#imageURL, #radius, #size)
{
background-image: url(#imageURL);
-webkit-border-radius:#radius;
-moz-border-radius:#radius;
border-radius:#radius;
background-position: center;
background-size: #size #size;
width: #size;
height: #size;
}
/***********************
Body
************************/
body
{
background-color: #primaryBackground;
width: 100%;
}
/***********************
Shells
************************/
.fixed-header-shell
{
width: 100%;
position: fixed;
top: 0px;
z-index: 10;
background-color: #primaryBackgroundDark;
}
.sections-shell
{
width: 100%;
margin-top: #defaultHeaderHeight;
min-height: 900px;
background-color: #primaryBackground;
}
.footer-shell
{
width: 100%;
background-color: #primaryBackgroundDark;
}
/***********************
Blocks
************************/
.fixed-header-block
{
background-color: #primaryBackgroundDark;
height: #defaultHeaderHeight;
clear: both;
width: 100%;
//padding-left: #defaultHeaderSidePadding;
//padding-right: #defaultHeaderSidePadding;
}
.section-block
{
background-color: #primaryBackground;
width: #defaultSectionWidth;
padding-top: #defaultSectionPadding;
padding-bottom: #defaultSectionPadding;
margin-right: auto;
margin-left: auto;
text-align: left;
border-style: solid;
border-bottom-width: 1.5px;
border-bottom-color: #divider;
}
.footer-block
{
background-color: #primaryBackgroundDark;
text-align: center;
padding-top: #defaultSectionPadding;
padding-bottom: #defaultSectionPadding;
height: #defaultFooterHeight;
}
/***********************
Header
************************/
.fixed-header-logo
{
.HeadingLogo;
.Clickable;
height: #defaultHeaderHeight;
line-height: #defaultHeaderHeight;
//margin-left: #defaultHeaderSidePadding;
text-align: left;
color: #white;
}
.fixed-header-nav
{
height: #defaultHeaderHeight;
//margin-right: #defaultHeaderSidePadding;
text-align: right;
}
.fixed-header-nav-link
{
.Clickable;
.HeadingLink;
line-height: #defaultHeaderHeight;
margin-left: 18px;
//margin-right: 9px;
color: #white;
}
/***********************
Footer
************************/
.footer-link
{
.Clickable;
text-align: center;
.fa
{
.Clickable;
color: #secondaryTextWhite;
width: 5em;
line-height: #defaultFooterHeight / 2;
}
}
.footer-text
{
.FooterText;
color: #secondaryTextWhite;
margin: auto;
line-height: #defaultFooterHeight / 2;
width: 24em;
}
/***********************
Sections
************************/
.section-block-text
{
.BodyText;
color: #text;
margin-top: #defaultSectionHeaderMargin;
}
.section-header
{
.SectionHeader;
text-align: left;
color: #text;
}
.section-sub-header
{
.SectionSubHeader;
margin-top: #defaultSectionHeaderMargin / 2;
color: #text;
}
/***********************
Columns
************************/
.col
{
display: block;
float:left;
margin: 0 0 0 0;
}
.span_2_of_2
{
width: 100%;
}
.span_1_of_2
{
width: 50%;
}
/***********************
Grouping
************************/
.group:before,
.group:after
{
content:"";
display:table;
}
.group:after
{
clear:both;
}
.group
{
zoom:1; /* For IE 6/7 */
width: 95%;
margin: auto;
}
/***********************
Intro
************************/
#intro
{
background-color: #primaryBackgroundDark;
text-align: center;
.section-block
{
border-style: none;
background-color: #primaryBackgroundDark;
}
}
#intro-avatar
{
.Image("../../content/images/profile2.png", 9999px, 200px);
margin: auto;
}
#intro-tagline
{
.HeadingTagline;
color: #white;
margin-top: 75px;
margin-left: auto;
margin-right: auto;
text-align: center;
}
/***********************
Posts
************************/
#details
{
border-style: none;
}
.post-link
{
.Clickable;
}
.post-date
{
text-align: left;
color: #secondaryText;
.PostDate
}
.post-title
{
.PostTitle;
.Clickable;
margin-top: 5px;
text-align: left;
color: #text;
}
.post-full-title
{
.PostTitle;
margin-top: 5px;
text-align: left;
color: #text;
}
.post-text
{
.BodyText;
margin-top: 5px;
text-align: left;
color: #text;
}
.post-full-text
{
.BodyText;
margin-top: 5px;
padding-bottom: 50px;
text-align: left;
color: #text;
border-style: solid;
border-bottom-width: 1.5px;
border-bottom-color: #divider;
}
.post-navigation
{
.Clickable;
.Button;
.BodyText;
display: inline-block;
margin-top: 50px;
}
/***********************
Projects
************************/
.project-section
{
text-align: left;
}
.project-title
{
.PostTitle;
margin-top: 5px;
text-align: left;
color: #text;
}
.project-text
{
.BodyText;
margin-top: 15px;
text-align: left;
color: #text;
}
.project-image
{
width: 100%;
//height: 450px;
border-color: #primaryLight;
border-width: 2px;
border-style: solid;
object-fit: contain;
object-position: center;
}
.project-link
{
.Clickable;
}
/***********************
Contact
************************/
#contact
{
.fa
{
color:#primaryAccent;
margin-right: 10px;
width: 24px;
}
}
/***********************
Links
************************/
#links
{
background-color: #primaryBackgroundOff;
h3
{
color:#primaryDark;
}
a
{
.Clickable;
color: #primaryDark;
text-align: center;
}
#facebook
{
.Image("../../content/images/facebook.png", 9999px, 75px);
margin: auto;
}
#linkedin
{
.Image("../../content/images/linkedin.png", 9999px, 75px);
margin: auto;
}
#google
{
.Image("../../content/images/google.png", 9999px, 75px);
margin: auto;
}
#github
{
.Image("../../content/images/github.png", 9999px, 75px);
margin: auto;
}
}
.resume-link
{
margin-top: 1.5em;
.Clickable;
.Button;
.BodyText;
display: inline-block;
}
/***********************
Media Queries
************************/
#media screen and (max-width: 1024px)
{
.fixed-header-block
{
//padding-right: #mediumSidePadding;
//padding-left: #mediumSidePadding;
}
.section-block
{
//padding-right: #mediumSidePadding;
//padding-left: #mediumSidePadding;
width: 70%;
}
}
#media screen and (max-width: 800px)
{
.fixed-header-shell
{
position: relative;
}
.fixed-header-nav
{
text-align: center;
height: #defaultHeaderHeight / 3;
}
.fixed-header-nav-link
{
line-height: #defaultHeaderHeight / 3;
margin-left: 15px;
margin-right: 15px;
}
.fixed-header-logo
{
text-align: center;
line-height: #defaultHeaderHeight * 2 / 3;
height: #defaultHeaderHeight * 2 / 3;
}
.fixed-header-block
{
//padding-right: #smallSidePadding;
//padding-left: #smallSidePadding;
}
.sections-shell
{
margin-top: 0;
}
.section-block
{
//padding-right: #smallSidePadding;
//padding-left: #smallSidePadding;
width: 90%;
}
.col
{
margin: 0 0 0 0%;
}
.span_2_of_2,
.span_1_of_2,
{
width: 100%;
}
#intro-tagline
{
font-size: 3.4em;
}
}
#media screen and (max-width: 480px)
{
#intro-tagline
{
font-size: 3em;
}
}
You have a fixed width of 24em on your .footer-text
Remove that and you will be good.
I am working on a mobile responsive website.
I have the navigation menu with the fixed position.
Right after I close the nav-menus div I have an image that has to be right under it. The thing is that the image goes under the fixed div of the menu.
What is the solution for this?
I want the yellow banner to be fully visible under the nav bar. now it's just under + behind it.
This is an example of what I have :
HTML code:
<!DOCTYPE html>
<html >
<body style="height:100%;">
<div data-role="panel" id="menu" class="" style="padding: 45px 0; margin: 0; " >
<div class="ui-panel-inner">
// the main menu in the background
</div>
</div>
<div id="superDiv" style="background-color: white; -webkit-transition: width 2s; transition: width 2s; height: 130%; ">
<div class="main" style="height: 100%;">
<div class="sidebar">
// menu items
</div>
<div class="header_space"></div> // I used this but it's now working good with precentages..
<img src="banner.png" id="mob-banner"/> // this is the banner
<div class="dynamicPage">
// content of the page..
</div>
</div>
</div>
</body>
</html>
The CSS code:
/******************/
/*** MOBILE ******/
/****************/
.header_space{
display: none;
height: 5.1%;
}
#mob-menu-btn{
display: none;
}
.sub-menu{
display: none;
}
#mob-home-btn{
display: none;
}
#mob-logo{
display: none;
}
#mob-banner{
display: none;
}
.makeFixed{
position: fixed;
}
/*****************************************************************/
#media (max-width: 604px) {
.main{
width: 100%;
/*overflow: hidden;*/
overflow-x: hidden;
}
.sidebar{
float: initial;
width: 100%;
padding: 0;
position: fixed;
z-index: 100;
background-image: url('top_background.png');
text-decoration: none;
}
.header_space{
display: inherit;
height: 4.7%;
}
.sports{
/*display: none;*/
padding: 0 ;
background-color: #fff;
margin: 0;
width:100%;
}
.list{
width: 100%;
overflow: hidden;
overflow-y: auto;
top: -10%;
overflow: hidden;
overflow-y: auto;
height: 880%;
display: none;
}
.sports li{
list-style-image:none;
list-style-type: none;
border-bottom: 2px solid #eeeeee;
margin-bottom: 0px;
margin-left: 0px;
/*padding-top: 15px;
padding-bottom: 15px;*/
padding-left: 10px;
width:100%;
font-family: arial;
text-decoration: none;
overflow: hidden;
/*height: 27px;*/
z-index: 100;
}
.sports a li {
text-decoration: none;
}
.sports2{
display: none;
margin-bottom: 0;
overflow: hidden;
}
.sub-menu{
display: inherit;
float: left;
cursor: pointer;
width: 30px;
/*margin-right: 20px;*/
position: relative;
bottom: 7px;
z-index: 900;
position: relative;
top: 7px;
padding-right: 17px;
}
.sports2 li{
list-style-image:none;
list-style-type: none;
border-bottom: 0px solid #eeeeee;
margin-bottom: 0px;
margin-left: 0px;
/*padding-top: 15px;
padding-bottom: 15px;*/
padding-left: 0px;
width:100%;
font-family: "arial";
text-decoration: none;
overflow: hidden;
}
.sports2 div{
padding: 15px 0;
}
#mob-menu-btn{
float: right;
width: 10%;
display: inherit;
cursor: pointer;
margin-top: 0.8%;
}
#mob-home-btn{
display: inherit;
cursor: pointer;
margin-top: 0.8%;
width: 10%;
float: left;
}
#mob-logo{
display: inherit;
text-align: center;
margin: 0.2% auto;
width: 30%;
}
#mob-banner{
display: inherit;
}
.banner{
display: none;
}
.content{
width:100%;
background-color: white;
}
.logo{
padding-top: 1px;
}
#cat-header{
display: none;
}
.line{
display: none;
}
.table {
width: 100%;
}
#top-pages{
display: none;
}
.top-pages{
display: none;
}
.category-link{
float:left;
padding-top: 25px;
width: 510px;
padding: 15px 0;
}
.content h1 {
color:#031c3f;
font-size:24px;
text-align: left;
font-family: "UScoreRGK";
margin-left: 7px;
}
.content p {
margin-left: 10px;
margin-right: 10px;
}
#active_line{
margin-left: 10px;
margin-right: 10px;
}
#menu {
z-index: 0;
top: 0px;
position: absolute;
/*right: 0px!important;
left: auto!important;*/
}
#menu li {
list-style: none!important;
}
}
#media (min-width : 414px) and (max-width : 533px) {
.category-link{
width: 460px;
}
}
#media (min-width : 375px) and (max-width : 414px) {
.category-link {
width: 340px;
}
.wcmText ul, ol{
margin: 0 0 1em -2.5em;
}
.wcmText p{
margin-top: 0;
}
.wcmText h1, h2{
margin-top: 0;
margin-bottom: 0;
font-size: 110%;
}
}
#media (min-width : 360px) and (max-width : 375px) {
.category-link {
width: 282px;
}
.sidebar{
height: 38px;
}
}
#media (min-width : 320px) and (max-width : 360px) {
.wcmText ul, ol{
margin: 0 0 1em -2.5em;
}
.wcmText p{
margin-top: 0;
}
.wcmText h1, h2{
margin-top: 0;
margin-bottom: 0;
font-size: 110%;
}
}
#media (min-width : 240px) and (max-width : 320px) {
.sidebar{
background-image: url('top_background-320-2.png');
height: 52px;
}
#mob-menu-btn {
width: 7%;
margin-top: 4.8%;
margin-right: 4%;
}
#mob-home-btn {
width: 7%;
margin-top: 4.8%;
margin-left: 4%;
}
#mob-logo {
margin: 2% auto;
width: 45%;
}
.header_space {
height: 52px;
}
.list {
width: 99.5%;
overflow: hidden;
overflow-y: auto;
top: -9%;
overflow: hidden;
overflow-y: auto;
height: 803%;
}
.sports li {
width: 96%;
}
.content h1 {
color:#031c3f;
font-size:24px;
text-align: left;
font-family: "UScoreRGK";
margin-left: 7px;
}
.content p {
margin-left: 10px;
margin-right: 10px;
}
.category-link{
float:left;
padding-top: 25px;
width: 230px;
padding: 15px 0;
}
}
It looks like the only thing you are missing to make the ".header_space" work is to add
style="height: 100%;" to your HTML tag
<html style="height: 100%;">
or in your CSS
html { height:100% }
all your height properties, for example "height:100%" on the BODY tag, are not working.
although, i don't think your solution is an elegant one.
I would prefer to add
#media (max-width: 604px) {
/* lets say 50px is the height of your mobile menu */
#mob-banner { margin-top: 50px; }
}
to the the media query that handles your mobile views, instead of
<div class="header_space"></div>
I am new to making responsive websites and from what I have discovered is that you can make a responsive website in 2 different ways, the first is by making everything fluid or like I have done, creating #media screen only and (min-width: 640px) { for a variety of window sizes (max-width: 639px, min-width: 640px, min-width: 760px, min-width: 1020px and min-width: 1280px).
With each of these media queries I have designed the website to suit certain devices in mind, for example 640px is aimed for iPhone. However when uploading the website and viewing it on my iPhone the page was really messed up with scaling all wrong which lead to adding <meta name = "viewport" content = "width = device-width"> but this has lead to my website showing the smallest media query on my iPhone. I can't get the website to display properly on my iPhone with the right media query but on my laptop when I adjust the window size the website changes appropriately.
What am I doing wrong?
The page can be seen here, ivybridgemethodistchurch.co.uk/DEV/index.html.
#media only screen and (max-width: 639px) {
#wrapper {
}
#ne_wrapper {
width: 500px;
margin: 0 auto;
padding-left: 20px;
padding-right: 20px;
padding-bottom: 20px;
}
.ne {
width: 100%;
height: 130px;
overflow: auto;
margin-top: 20px;
background: #FFF;
position: relative;
}
.ne img {
width: 130px;
margin: 0;
float: left;
position: absolute;
z-index: 100;
}
#ne_tag {
padding: 5px 0;
margin: 0;
position: absolute;
z-index: 200;
top: 0;
left: 0;
background: rgba(67, 149, 142, 0.85);
}
#ne_tag small {
color: #FFF;
margin: 0;
margin-left: 20px;
margin-right: 20px;
padding: 0;
}
#ne_container {
width: 330px;
margin: 20px;
float: right;
}
#ne_title {
margin-bottom: 10px;
}
#te_wrapper {
width: 500px;
margin: 40px auto;
padding-left: 20px;
padding-right: 20px;
}
.te {
width: 500px;
height: 500px;
padding: 0;
position: relative;
overflow: auto;
}
.te img {
width: 100%;
position: absolute;
z-index: 100;
}
#te_container {
margin: 10px;
float: left;
position: absolute;
z-index: 200;
}
#te_title {
float: left;
padding: 15px;
background: #FFF;
}
#te_title h1 {
float: left;
}
#te_details {
float: left;
padding: 15px;
background: #FFF;
}
#te_tag {
float: left;
clear: both;
padding: 5px 0;
margin: 0;
background: rgba(67, 149, 142, 1);
}
#te_tag small {
color: #FFF;
margin: 0;
margin-left: 20px;
margin-right: 20px;
padding: 0;
}
#te_description {
display: none;
}
#pe_wrapper {
width: 500px;
margin: 0 auto;
padding-left: 20px;
padding-right: 20px;
padding-bottom: 20px;
}
.pe {
width: 100%;
overflow: auto;
margin-top: 10px;
padding-bottom: 10px;
border-bottom: 1px solid #FFF;
}
.pe img {
width: 100px;
float: left;
margin-right: 10px;
}
#pe_container {
width: 350px;
overflow: auto;
float: right;
padding: 20px;
background: #FFF;
}
#pe_title {
padding-bottom: 10px;
margin-bottom: 15px;
border-bottom: 1px solid #DDD;
}
.no_1 {
margin-top: 20px;
}
}
#media only screen and (min-width: 640px) {
#nav {
width: 100%;
height: 55px;
background: red;
border-bottom: 1px solid #DDD;
position: absolute;
}
#outer {
top: 55px;
width: 100%;
position: absolute;
}
#wrapper {
}
#ne_wrapper {
background: purple;
width: 600px;
margin: 0 auto;
padding-left: 20px;
padding-right: 20px;
padding-bottom: 20px;
}
.ne {
width: 100%;
min-height: 150px;
overflow: auto;
margin-top: 20px;
background: #FFF;
position: relative;
}
.ne img {
width: 150px;
float: left;
position: absolute;
z-index: 100;
}
#ne_container {
width: 410px;
margin: 20px;
float: right;
}
#ne_title {
padding-bottom: 10px;
margin-bottom: 10px;
border-bottom: 1px solid #DDD;
}
#ne_tag {
padding: 5px 0;
margin: 0;
position: absolute;
z-index: 200;
top: 0;
left: 0;
background: rgba(67, 149, 142, 0.85);
}
#ne_tag small {
color: #FFF;
margin: 0;
margin-left: 20px;
margin-right: 20px;
padding: 0;
}
#te_wrapper {
width: 600px;
height: auto;
margin: 40px auto;
padding-left: 20px;
padding-right: 20px;
}
.te {
width: 600px;
height: auto;
padding: 0;
position: relative;
overflow: auto;
}
.te img {
width: 350px;
float: left;
position: relative;
}
#te_container {
width: 250px;
margin: 0;
float: right;
position: inherit;
}
#te_tag {
padding: 5px 0;
margin: 0;
position: absolute;
z-index: 200;
top: 0;
left: 0;
background: rgb(67, 149, 142);
}
#te_tag small {
color: #FFF;
margin: 0;
margin-left: 20px;
margin-right: 20px;
padding: 0;
}
#te_title {
width: 220px;
float: left;
padding: 15px;
background: rgba(255, 255, 255, 0.95);
}
#te_title h1 {
float: left;
}
#te_details {
width: 220px;
float: left;
margin-top: 1px;
padding: 15px;
background: rgba(255, 255, 255, 0.95);
}
#te_description {
display: none;
}
#pe_wrapper {
width: 600px;
margin: 0 auto;
padding-left: 20px;
padding-right: 20px;
padding-bottom: 20px;
}
.pe {
width: 100%;
overflow: auto;
margin-top: 20px;
background: #FFF;
}
.pe img {
width: 120px;
float: left;
}
#pe_title {
padding-bottom: 10px;
margin-bottom: 10px;
border-bottom: 1px solid #DDD;
}
#pe_container {
width: 440px;
margin: 20px;
float: left;
}
}
#media only screen and (min-width: 760px) {
#wrapper {
}
#ne_wrapper {
width: 720px;
}
#ne_container {
width: 530px;
}
#te_wrapper {
width: 720px;
margin-bottom: 20px;
}
.te {
width: 720px;
}
#te_container {
width: 370px;
}
#te_title {
width: 340px;
}
#te_details {
max-width: 340px;
}
#pe_wrapper {
width: 720px;
overflow: auto;
}
#st {
width: 350px;
float: left;
}
#nd {
width: 350px;
float: right;
}
.pe {
width: 350px;
height: 457px;
position: relative;
}
.pe img {
width: 350px;
}
#pe_container {
width: 310px;
margin: 10px;
padding: 10px;
height: auto;
position: absolute;
bottom: 0;
background: #FFF;
}
}
#media only screen and (min-width: 1020px) {
#wrapper {
width: 980px;
margin: 0 auto;
}
#ne_wrapper {
width: 910px;
float: left;
}
.ne {
width: 700px;
background: transparent;
border-left: 10px solid rgb(67, 149, 142);
}
#ne_inner {
margin-left: 20px;
}
#ne_tag {
display: none;
}
#ne_container {
width: 490px;
min-height: 110px;
background: #FFF;
padding: 20px;
margin: 0;
}
#te_wrapper {
width: 940px;
}
.te {
width: 740px;
}
#te_container {
width: 340px;
padding: 20px;
background: #FFF;
}
#te_title,
#te_details {
margin: 0;
padding: 0;
}
#te_title {
padding-bottom: 10px;
border-bottom: 1px solid #DDD;
}
#te_details {
padding-top: 10px;
}
#pe_wrapper {
width: 940px;
clear: both;
}
#st,
#nd {
width: 100%;
float: left;
clear: both;
}
.pe {
width: 300px;
height: 405px;
float: left;
background: #FFF;
}
.pe img {
width: 300px;
}
#pe_container {
width: 260px;
}
.no_1,
.no_2,
.no_4,
.no_5 {
margin-right: 20px;
}
}
#media only screen and (min-width: 1280px) {
#wrapper {
width: 1120px;
margin: 0 auto;
overflow: auto;
}
#ne_wrapper {
width: 1090px;
margin: 0 auto;
padding-left: 0;
padding-right: 0;
float: left;
padding-bottom: 20px;
}
.ne {
width: 730px;
}
#ne_container {
width: 520px;
}
#te_wrapper {
width: 1120px;
}
.te {
width: 1120px;
height: 360px;
position: relative;
}
.te img {
width: 360px;
position: absolute;
z-index: 100;
}
#te_container {
width: auto;
position: absolute;
z-index: 200;
top: 20px;
left: 350px;
margin: 0;
padding: 0;
background: transparent;
}
#te_tag {
background: rgb(67, 149, 142);
}
#te_title {
width: auto;
max-width: 730px;
overflow: auto;
float: none;
padding: 20px;
margin: 0;
margin-top: 28px;
background: #FFF;
border-bottom: 1px solid #F4F1EB;
}
#te_details {
float: none;
overflow: auto;
padding: 20px;
margin: 0;
background: #FFF;
border-bottom: 1px solid #F4F1EB;
}
#te_description {
display: block;
width: 730px;
position: absolute;
z-index: 200;
margin: 0;
padding: 20px;
background: #FFF;
}
#te_description h5 {
margin: 0;
padding: 0;
font-family: 'Roboto', sans-serif;
font-weight: 300;
}
#pe_wrapper {
width: 1120px;
margin: 0 auto;
clear: both;
padding-left: 20px;
padding-right: 20px;
padding-bottom: 20px;
}
#st,
#nd {
width: 100%;
float: left;
clear: both;
}
.pe {
width: 360px;
height: 480px;
}
.pe img {
width: 360px;
}
#pe_container {
width: 300px;
margin: 20px;
}
.no_1,
.no_2,
.no_4,
.no_5 {
margin-right: 20px;
}
}
#media only screen and (min-width: 1360px) {
}
Your media queries are not correct
#media only screen and (max-width: 639px) { }
#media only screen and (min-width: 640px) { }
#media only screen and (min-width: 760px) { }
#media only screen and (min-width: 1020px) { }
#media only screen and (min-width: 1280px) { }
#media only screen and (min-width: 1360px) { }
This will result in applying styles of #media only screen and (max-width: 639px) { } because all other media queries are overridden by it as you have given min-width to all queries, thus it takes lowest min-width and applies it for all sizes.
Change it to
#media only screen and (max-width: 639px) { }
#media only screen and (min-width: 640px) and (max-width: 759px) { }
#media only screen and (min-width: 760px) and (max-width: 1019px) { }
#media only screen and (min-width: 1020px) and (max-width: 1279px) { }
#media only screen and (min-width: 1280px) and (max-width: 1359px) { }
#media only screen and (min-width: 1360px) { }
To explain you media queries in detail, refer css getting changed when applying css media queries for responsive design
I will also put some part of that answer here for further reviews of this post.
include this in <head></head> (if you have not)
<meta name="viewport" content="width=device-width, user-scalable=no" /> <-- user-scalable=yes if you want user to allow zoom -->
change you #media style as this // change width as per your requirements
#media only screen (max-width: 500px) {
// or as per your needs, as I try to explain below
}
Now I try to explain maybe..:)
#media (max-width:500px)
for a window with a max-width of 500px that you want to apply these styles. At that size you would be talking about anything smaller than a desktop screen in most cases.
#media screen and (max-width:500px)
for a device with a screen and a window with max-width of 500px apply the style. This is almost identical to the above except you are specifying screen as opposed to the other media types the most common other one being print.
#media only screen and (max-width:500px)
Here is a quote straight from W3C to explain this one.
The keyword ‘only’ can also be used to hide style sheets from older user agents. User agents must process media queries starting with ‘only’ as if the ‘only’ keyword was not present.
As there is no such media type as "only", the style sheet should be ignored by older browsers.
Example
#media all and (min-width: 500px) {
}
#media all and (max-width: 500px) and (min-width: 300px) {
}
#media all and (max-width: 299px) {
}