I do not know css and it seems hard to display a menu through my self-hosted wordpress site theme in the mobile version. The idea is to use the following code:
#sidebar-primary { display: none; }
Though seems that nothing happens when I add it. Is there a way to hide this element? Below is th whole code when the mobile version is present. Thanks
#media only screen and (max-width: 767px) {
.wrap { max-width: 300px; }
#branding {
float: left;
width: 100%;
position: relative;
}
#sidebar-header {
width: 100%;
margin-bottom: 10px;
}
.featured-wrapper, .aside, .content-wrap, #content, #sidebar-subsidiary .widget, #respond { width: 100%; }
.featured-post h2.entry-title a {
font-size: 12px;
line-height: 1.4em;
padding-right: 15px;
bottom: 87px;
}
.featured-post .byline {
bottom: 63px;
padding: .25em 15px .25em 1.3em;
}
.home.singular .byline { font-size: 10px; }
.menu-toggle {
display: block;
width: 100%;
}
#menu-primary {
float: left;
clear: both;
width: 100%;
margin-top: 10px;
}
#menu-primary .menu, .menu ul {
float: left;
width: 100%;
}
#menu-primary ul li {
clear: left;
display: block;
padding-left: 0;
background: none;
}
#menu-primary ul li a {
font-size: 20px;
margin-left: 0;
padding: 12px 15px;
}
#menu-primary li li a { font-size: 18px; }
#menu-primary li ul, #menu-primary li li { border: none !important; }
#menu-primary li li a:hover { background: none; }
#menu-primary ul li ul {
display: block !important;
float: left !important;
visibility: visible !important;
}
#menu-primary li ul {
display: block !important;
position: relative !important;
top: 0;
left: 30px;
}
#menu-primary ul li li ul { left: 30px !important; }
#menu-primary li:hover ul, #menu-primary li.sfHover ul {
display: block !important;
top: 0 !important;
}
#menu-primary li:first-child ul { left: 0; }
#menu-primary .sf-sub-indicator { background: none !important; }
#menu-secondary .sf-sub-indicator { background: none !important; }
.hentry {
width: 100%;
margin-right: 0;
}
.page-template-front .hentry:hover .read-more, .archive .hentry:hover .read-more, .search .hentry:hover .read-more { display: none; }
.page-template-front .hfeed-more .hentry {
float: left;
width: 100%;
margin-right: 0;
}
.comment-list li li { padding-left: 0; }
#sidebar-primary, #sidebar-secondary, #sidebar-subsidiary {
width: 100%;
clear: left;
}
#footer-content, #menu-subsidiary {
width: 100%;
margin-bottom: 20px;
}
#menu-subsidiary .menu { float: left; }
#menu-subsidiary li {
background: none;
float: none;
padding-left: 0;
margin-bottom: .4em;
}
#menu-subsidiary li a {
font-size: 10px;
line-height: 2.5em;
}
textarea { width: 96%; }
}
If it is not working then it looks like the style for mobile devices are defined in different #media query
Mostly max-width : 320px #media query is used for mobile devices
For mobile devices max-width : 320px just check if it is there and add styles in that query
#media only screen
and (max-width : 320px) {
/* Styles */
}
and more information on #media queries can be found here and here
Did you try adding !important to your style?
#sidebar-primary { display: none; !important}
Are you sure that you have not missed any other
#media only screen and (max-width: xyz px)
May be
#media only screen and (max-width: 767px)
style are not calling.
Check with other #media tag if exists in css.
The right way to force the element to not be displayed is to use the css below:
#sidebar-primary { display: none !important;}
semi-colon after !important
Even if you set the display to none it will still appear when you inspect the dom element. To remove it entirely you need to use jquery or javascript the triggers on document ready that removes the element.
$(document).ready(function(){
if($(window).width() < 767){
$('#sidebar-primary').remove();
}
})
Hope this helps
Related
my logo is not responsive on mobile phones.
Code below. Wordpress theme: xclean.
Can anyone help please?
Thank you.
/*=============================================
= Mobail Menu Style =
=============================================*/
.header-search {
right: 0;
}
.header-search .searchform input[type="text"] {
width: 160px !important;
}
.header-search .searchform input[type="submit"] {
width: 35px !important;
}
.header .site-logo a {
display: block;
text-align: center;
}
.header .site-logo .slideItWrapper {
display: inline-block;
}
.header-cart:hover .dropdown {
visibility: hidden;
opacity: 0;
}
.header-cart .dropdown {
display: none;
}
Use Relative units of measure:
.header .site-logo a {
width: 10vw;
}
i need to make my responsive css page content 100 % min-height ... i need help..
#media (min-width: 980px) and (max-width: 1280px) {
.page-boxed .header .dropdown .username {
display: none;
}
}
#media (min-width: 980px) {
/***
Page sidebar
***/
.page-sidebar {
position: absolute;
width: 225px;
min-height:100%;
}
.page-sidebar-fixed .page-sidebar {
position: fixed !important;
top: 41px;
}
.page-sidebar-fixed ul.page-sidebar-menu > li.last {
margin-bottom: 15px !important;
}
.page-sidebar-fixed.page-sidebar-hover-on .page-sidebar {
z-index: 10000;
width: 35px;
}
.page-sidebar-fixed.page-sidebar-hover-on .page-sidebar .selected {
display: none;
}
.page-sidebar-fixed.page-sidebar-hover-on .page-content {
margin-left: 35px;
}
.page-sidebar-fixed.page-sidebar-hover-on .footer {
margin-left: 35px;
}
.page-sidebar-fixed .page-sidebar-closed .page-sidebar .sidebar-search .submit,
.page-sidebar-fixed .page-sidebar .sidebar-toggler {
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
-o-transition: all 0.2s ease;
transition: all 0.2s ease;
}
.page-sidebar-hovering {
overflow: hidden !important;
}
.page-sidebar-hovering .sub-menu,
.page-sidebar-hovering span.title,
.page-sidebar-hovering span.arrow {
display: none !important;
}
.page-sidebar-hovering .submit {
opacity: 0;
width: 0 !important;
height: 0 !important;
}
/***
Page content
***/
.page-content {
margin-left: 225px;
margin-top: 0px;
min-height: 760px;
}
.page-sidebar-fixed .page-content {
min-height: 600px;
}
.page-content.no-min-height {
min-height: auto;
}
/***
Footer
***/
/* fixed sidebar */
.page-sidebar-fixed .footer {
margin-left: 225px;
background-color: #fff;
}
.page-sidebar-fixed .footer .footer-inner {
color: #333;
}
.page-sidebar-fixed.page-sidebar-closed .footer {
margin-left: 35px;
}
.page-sidebar-fixed .footer .footer-tools .go-top {
background-color: #666;
}
.page-sidebar-fixed .footer .footer-tools .go-top i {
color: #ddd;
}
/* boxed layout */
.page-boxed .header .brand {
margin-left: 0px !important;
width: 226px;
}
.page-boxed .header .brand img {
margin-left: 10px;
}
}
/***
For tablets and phones
***/
#media (max-width:979px) {
/***
Body
***/
body {
margin: 0px !important;
}
/***
Page header
***/
.header {
margin: 0 !important;
}
.header .nav li.dropdown i {
display: inline-block;
position: relative;
top:1px;
right:0px;
}
.header .nav {
margin-bottom: 0px !important;
}
.header .brand {
margin-left: 0px !important;
padding-left: 0px !important;
}
.header .brand img {
margin-left: 2px !important;
}
/***
Page container
***/
.page-container {
margin: 0 !important;
padding: 0 !important;
}
.page-header-fixed .page-container {
margin-top: 0px !important;
}
/***
Page content
***/
.page-content {
margin: 0px !important;
padding: 0px !important;
min-height: 280px;
}
/***
Page sidebar
***/
.page-sidebar {
margin: 0 10px;
}
.page-sidebar.in {
margin: 15px;
position: relative;
z-index: 5;
}
.page-sidebar .sidebar-toggler {
display: none;
}
.page-sidebar ul {
margin-top:0px;
width:100%;
}
.page-sidebar .selected {
display: none !important;
}
.page-sidebar .sidebar-search {
width: 220px;
margin-top: 20px;
margin-bottom:20px;
}
/***
Page title
***/
.page-title {
margin: 15px 0px;
}
/***
Styler panel
***/
.styler-panel {
top:55px;
right:20px;
}
}
#media (min-width: 768px) and (max-width: 1280px) {
/***
Form wizard
***/
.form-wizard .step .desc {
margin-top: 10px;
display: block;
}
/***
Pricing tables
***/
.pricing-table .rate .price,
.pricing-table2 .rate .price {
width: 100%;
display: block;
text-align: center;
margin-bottom: 10px;
}
}
#media (min-width: 768px) and (max-width: 979px) {
/***
Body
***/
body {
padding-top: 0px;
}
/***
Page sidebar
***/
.page-sidebar .btn-navbar.collapsed .arrow {
display: none;
}
.page-sidebar .btn-navbar .arrow {
position: absolute;
right: 25px;
width: 0;
height: 0;
top:50px;
border-bottom: 15px solid #5f646b;
border-left: 15px solid transparent;
border-right: 15px solid transparent;
}
}
#media (max-width: 767px) {
/***
Page header
***/
.header .navbar-inner .container-fluid,
.header .navbar-inner .container {
margin-left: 10px !important;
margin-right: 10px !important;
}
.header .top-nav .nav{
margin-top: 0px;
margin-right: 5px;
}
.header .nav > li > .dropdown-menu.notification:after,
.header .nav > li > .dropdown-menu.notification:before {
margin-right: 180px;
}
.header .nav > li > .dropdown-menu.notification {
margin-right: -180px;
}
.header .nav > li > .dropdown-menu.inbox:after,
.header .nav > li > .dropdown-menu.inbox:before {
margin-right: 140px;
}
.header .nav > li > .dropdown-menu.inbox {
margin-right: -140px;
}
.header .nav > li > .dropdown-menu.tasks:after,
.header .nav > li > .dropdown-menu.tasks:before {
margin-right: 90px;
}
.header .nav > li > .dropdown-menu.tasks {
margin-right: -90px;
}
/* Header logo */
.header .brand {
margin-left: 0px !important;
width: 110px;
}
/***
Page content
***/
.page-content {
padding: 10px !important;
}
/***
Page title
***/
.page-title {
margin-bottom: 20px;
}
/***
Styler pagel
***/
.styler-panel {
top:58px;
right:12px;
}
/***
Page breadcrumb
***/
.breadcrumb {
padding-left: 10px;
padding-right: 10px;
}
/***
Portlet form action
***/
.portlet-body.form .form-actions{
padding-left: 15px;
}
/***
Gritter notification
***/
#gritter-notice-wrapper {
right:1px !important;
}
/***
Form input validation states
***/
.input-icon .input-error,
.input-icon .input-warning,
.input-icon .input-success {
top:-27px;
float: right;
right:10px !important;
}
/***
Advance tables
***/
.table-advance tr td.highlight:first-child a {
margin-left: 8px;
}
/***
Footer
***/
.footer {
padding-left: 10px;
padding-right: 10px;
}
.footer .go-top {
float: right;
display: block;
margin-right: 0px;
}
/***
Vertical inline menu
***/
.ver-inline-menu li.active:after {
display: none;
}
/***
Form controls
***/
.form-horizontal .form-actions {
padding-left: 180px;
}
.portlet .form-horizontal .form-actions {
padding-left: 190px;
}
}
#media (max-width: 480px) {
/***
Header navbar
***/
.header .nav {
clear:both !important;
}
.header .nav > li.dropdown .dropdown-toggle {
margin-top:3px !important;
}
.header .nav li.dropdown .dropdown-toggle .badge {
top: 11px;
}
/***
Page sidebar
***/
.page-sidebar.in {
margin-top: 7px !important;
}
/***
Styler panel
***/
.styler-panel {
top:92px;
right:12px;
}
/***
Page title
***/
.page-title small {
display: block;
clear: both;
}
/***
Dashboard date range panel
***/
.page-content .breadcrumb .dashboard-date-range {
padding-bottom: 8px;
}
.page-content .breadcrumb .dashboard-date-range span {
display: none;
}
/***
Login page
***/
.login .logo {
margin-top:10px;
}
.login .content {
padding: 30px;
width: 222px;
}
.login .content h3 {
font-size: 22px;
}
.login .content .m-wrap {
width: 180px;
}
.login .checkbox {
font-size: 13px;
}
/***
Form controls
***/
.form-horizontal.form-bordered .control-label {
float: none;
width: auto;
padding-top: 0;
text-align: left;
margin-top: 0;
margin-left: 10px;
}
.form-horizontal.form-bordered .controls {
padding-top: 0 !important;
border-left: 0 !important;
}
.form-horizontal.form-bordered.form-label-stripped .control-group:nth-child(even) {
background-color: none !important;
}
.form-horizontal.form-bordered.form-label-stripped .control-group:nth-child(even) .controls {
background-color: none !important;
}
.form-horizontal.form-row-seperated .control-label {
float: none;
width: auto;
padding-top: 0;
text-align: left;
margin-left: 10px;
}
.form-horizontal.form-row-seperated .controls {
border-left: 0;
margin-left: 10px;
}
.portlet .form-horizontal .form-actions {
padding-left: 10px;
}
/***
Hidden phone
***/
.hidden-480 {
display: none;
}
/***
Modal header close button fix
***/
.modal-header .close {
margin-top: 5px !important;
}
/***
Fix text view
***/
.control-group .controls .text {
display: block !important;
margin-bottom: 10px;
}
}
#media (max-width: 320px) {
.header .nav > li.dropdown .dropdown-toggle {
padding-left: 8px !important;
padding-right: 8px !important;
}
/***
Hidden phone
***/
.hidden-320 {
display: none;
}
.header .brand {
width: 100px;
}
}
You may want to look at the MDN article on min-height
The min-height CSS property is used to set the minimum height of a
given element. It prevents the used value of the height property from
becoming smaller than the value specified for min-height.
Specifically- you need to also define the height when declaring min-height, as that is what min-height is calculated relative to.
If the height of the containing block is not specified explicitly
(i.e., it depends on content height), and this element is not
absolutely positioned, the percentage value is treated as 0.
The most common way to have content 100% of viewport height is to assign a height value of 100% to the html and body elements, then the main page 'container'. One other approach is to have an absolutely positioned element with a top and bottom setting of zero.
my bootstrap mobile style won't render unless I add a extra closing brace to the end can someone tell me what I did wrong
this is the styles that I created and they should work but they are not working and they pass the validator test.
#media only screen and (max-width: 766px){
.movie{
width:300px;
height: 300px;
margin:0;
padding:0;
}
body > div > div > h3 {
margin-left: 300px;
padding-top: 200px;
}
a:link {
outline: 0;
font-size: 9px;
display: block;
padding-right: 50px;
}
h3{
font-size: 20px;
margin-top:20%;
}
h3.port {
margin-left: 150px;
color: #9932CC;
margin-top: 50px;
}
img {
float: left;
margin-right: 15px;
width:50%;
height:50%;
margin-top:0;
}
p {
margin-left: 10px;
margin-top:5%;
padding: 0;
color: #9932CC;
font-size: 15px;
}
.navbar .nav > li > a {
color: #9932CC;
}
body > div > div > a > img {
display: none;
}
.navbar-brand {
float: left;
padding: 10px 15px;
font-size: 20px;
}
/* twitter
====================================== */
div#iPhone {background: url("../images/iphone.png") no-repeat;
width:275px;height:500px;
display: inline-block;
padding-top: 90px;
padding-left:2em;
margin-left: 0px;
}
iframe#twitter-widget-0.twitter-timeline[style] {width:70px !important;}
div#iPhone iframe[id^="twitter-widget-0"] {min-width:170px !important;
margin-right: 20px;
}
/* iframe
======================================= */
.movie {
text-align: center;
width: 350px;
height: 345px;
margin-left: 0px;
margin-right: 200px;
}
.paragraph {
width: 50px;
margin-left: 10%;
}
.thumbnail {
color: #333;
margin-left: 100%;
width: 100%;
background-color: transparent;
border:0px;
}
.btn-primary {
color: #000;
background-color: #aff6b8;
border-color:black;
margin-top: 5%;
width:100%;
}
}
}
mobile style won't render unless I add a extra closing brace to the end
Yes, the #media syntax involves an extra set of braces:
#media only screen and (max-width: 766px) {
element {}
}
The last closing brace you added is equivalent to the last one in the code above.
I'm doing a site using JSBin.
It's at http://jsbin.com/alajih/10
The issue is the mobile size I'm doing. The first image stacks fine. The second image does a weird thing where it juts to the right and isn't aligned to with the top image. Not sure why that's happening.
Here's some of the code:
#media (max-width: 767px) {
.contacttext {
font-size: 19px;
font-weight: bold;
vertical-align:middle;
}
.nav {
margin: 0;
}
.contact > li {
display:block;
width:767px;
float:none;
}
.social{
color: #fff;
display:block;
float:none;
}
li {
padding: 7px 20px 0 0px;
}
row-fluid > .span8 {
width:100%;
display: block;
float: none;
}
.span4 {
width:100%;
display: block;
float: none;
}
.row-fluid [class*="span"] {
float: none;
width: 100%;
}
.row-fluid > .firstpic {
padding: 0 0 20px 0;
}
}
Modify the css adding:
.row-fluid [class*="span"] {
margin-left: 0px;
}
I'm wondering why some of my media queries are not overriding the native styles at the view port their being called. I'm trying to restyle a menu responsively, to stack, and have the navigation area's height longer in a WP theme. But every which way I add the specs I create to get this effect via editing Live CSS in Safari or FF inspect element - the styles I insert under the specific viewport I'm targeting are not being read. I know I'm using media queries correctly as it reads NEW styles, just doesn't override native? I'm missing something here? Here's what I'm trying to add that won't read.
#media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
#access li {
float: none; // To translate to not to float to the left stack
position: relative;
}
#access {
background: url("http://testsite.com/wp-content/uploads/2012/01/menu_bg.gif") repeat scroll 0 0 transparent;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
clear: both;
display: block;
float: left;
height: 240px; //Changed the height to allow stack
width: 100%;
}
Edit: Here's the FULL set of Responsive styles I'm calling, if matters.
/* =Responsive Structure
----------------------------------------------- */
#media (max-width: 800px) {
body {
padding: 0;
}
#page {
margin-top: 0; overflow: hidden;
}
#branding {
border-top: none;
}
#signup { display:none; }
#adbox { display:none; }
#adbox2 { display:none; }
#socialpost { margin-left: -100px; }
p {font-size: 12px; }
#sublogo { display: none; }
#footcontain { padding-left: 0;}
#access a {
color: #000000;
display: block;
font-family: arial;
line-height: 3.11em;
padding: 0 20px;
text-decoration: none;
#access a { font-size: 12px; }
#access li {
float: left;
margin-left: -28px;
position: relative; }
}
#media (max-width: 650px) {
/* #media (max-width: 650px) Reduce font-sizes for better readability on smaller devices */
body {
padding: 0;
}
#page {
margin-top: 0;
}
#branding {
border-top: none;
}
#signup { display:none; }
#adbox { display:none; }
#adbox2 { display:none; }
p {font-size: 12px; }
#sublogo { display: none; }
#access a {
color: #000000;
display: block;
font-family: arial;
line-height: 3.11em;
padding: 0 13px;
text-decoration: none;
font-size: 11px;}
#footcontain { padding-left: 0;}
#access a {
padding: 0 15px; }
}
#media (max-width: 450px) {
#content .gallery-columns-2 .gallery-item {
width: 45%;
padding-right: 4%;
}
#content .gallery-columns-2 .gallery-item img {
width: 100%;
height: auto;
}
#signup { display:none; }
#adbox { display:none; }
#adbox2 { display:none; }
p {font-size: 10px; }
.entry-content, .entry-summary {
padding: 1.625em 0 0;
width: 48%; }
#footcontain { padding-left: 0;}
#branding #s {
-moz-transition-duration: 400ms;
-moz-transition-property: width, background;
-moz-transition-timing-function: ease;
float: right;
height: 35px;
width: 47px; }
.widget-title { margin-top: 35px; }
.flexslider .slides img {
border: 0 none;
display: block;
max-width: 100%;
padding-bottom: 25px; }
#footcontain { display:none;}
#access li {
float: none;
position: relative;
}
#access {
height: 70px;
}
#access a {
color: #000000;
display: block;
font-family: arial;
font-weight: bolder;
line-height: 3.11em;
padding: 0 10px;
text-decoration: none;
}
#access ul {
font-size: 10px;
list-style: none outside none;
margin: 0 0 0 -80px;
padding-left: 0;
}
.flex-control-nav { display: none; }
.flexslider {
margin: 0 0 67px; }
.flex-caption { display: none; } //Could Display this here, need to make take half of slider
}
#media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
body { padding: 0; }
#access {
height: 70px;
}
#page {
margin-top: 0; overflow: hidden;
}
#branding {
border-top: none;
}
#signup { display:none; }
#adbox { display:none; }
#adbox2 { display:none; }
p {font-size: 10px; }
#sublogo { display: none; }
#access a { padding: 0 10px; }
#access li {
float: none;
position: relative;
}
.entry-content, .entry-summary {
padding: 1.625em 0 0;
width: 35%; }
#footcontain { display: none; }
#branding #s {
-moz-transition-duration: 400ms;
-moz-transition-property: width, background;
-moz-transition-timing-function: ease;
float: right;
height: 35px;
width: 47px; }
#footcontain { display: none; }
.widget-title { margin-top: 35px; } //Attempt to Create Space for Slider Page Nation
#access { height: 70px; }
#access li {
float: none;
position: relative;
}
.flex-control-nav { display: none; }
.flex-caption { display: none; } //Could Display this here, need to make take half of slider, check
.flexslider {
margin: 0 0 67px; }
}
The CSS code from your post is not working because it's a device-specific style and you are viewing it on a Safari, Chrome or Firefox using a laptop/desktop. You are forgetting that Media Queries are giving you the possibility to apply different styles when a page is being displayed in a 'browser' - resized to 480px and on an iPhone (which has a max-device-width of 480px).
Example CSS:
/* max-width */
#media screen and (max-width: 480px) {
.one {
background: #F9C;
}
}
/* min-width & max-width */
#media screen and (min-width: 480px) and (max-width: 900px) {
.two {
background: #9CF;
}
}
/* min-width */
#media screen and (min-width: 900px) {
.three {
background: #F90;
}
}
/* iphone specific css */
#media screen and (max-device-width: 480px) {
.iphone {
background: #ccc;
}
}
In the example above you can target both and still have a separate style for your device of choice. If you want to test it in a browser just use the min-width or max-width properties.
Hope this helps.
On the top example there's a missing closing bracket.
#media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
#access li {
float: none; // To translate to not to float to the left stack
position: relative;
}
#access {
background: url("http://testsite.com/wp-content/uploads/2012/01/menu_bg.gif") repeat scroll 0 0 transparent;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
clear: both;
display: block;
float: left;
height: 240px; //Changed the height to allow stack
width: 100%;
}
}