I have a simple media query that isn't working... here is my code:
In an external stylesheet:
#media screen and (max-width: 768px) {
.logo_1000{display:none !important;}
.logo_320{display:visible !important;}
}
Next, in the html of my PHP Header file I have two sets of Logo HTML, each in its own wrapper with one of the classes above:
<div class="logo_1000" style="margin: 0px auto 0px; width: 1000px; height:100px;">
<div style="width:100%; height:100px; display:inline-block;"><img src="http://www.bangorchildcare.com/wp-content/uploads/2016/04/logo-1000x100.png" width="1000" height="100" /></div>
</div>
<div class="logo_320" style="display:none; margin: 0px auto 0px; width: 100%; height:100px;">
<div style="width:100%; height:100px; display:inline-block;"><img src="http://www.bangorchildcare.com/wp-content/uploads/2016/04/logo-320-100.png" width="320" height="100" /></div>
</div>
It doesn't work because the browser will always use inline css over css defined by "" over external styles.
Maybe you want to use Chrome DevTools (F12), they will make your life much easier
there is value of display is not correct, there is no such a thing as visible, it should be something from the list defined to the property, see http://www.w3schools.com/cssref/pr_class_display.asp for valid values.
Usually, if you hover your mouse over the yellow warning mark, it says what is wrong.
You are misusing the display property of css.
The display property specifies the type of box used for an HTML element.
There is no such thing as display: visible;.
Have a look in here
inline Default value. Displays an element as an inline element like span
block Displays an element as a block element like p
flex Displays an element as an block-level flex container. New in CSS3
inline-block Displays an element as an inline-level block container. The inside of this block is formatted as block-level box, and the element itself is formatted as an inline-level box
inline-flex Displays an element as an inline-level flex container. New in CSS3
inline-table The element is displayed as an inline-level table
list-item Let the element behave like a li element
run-in Displays an element as either block or inline, depending on context
table Let the element behave like a table element
table-caption Let the element behave like a caption element
table-column-group Let the element behave like a colgroup element
table-header-group Let the element behave like a thead element
table-footer-group Let the element behave like a tfoot element
table-row-group Let the element behave like a tbody element
table-cell Let the element behave like a td element
table-column Let the element behave like a col element
table-row Let the element behave like a tr element
none The element will not be displayed at all (has no effect on
layout)
initial Sets this property to its default value. Read about initial
inherit Inherits this property from its parent element.
Sample css:
#media only screen and (max-width: 768px) {
.logo_1000{display:none !important;}
.logo_320{display:block !important;}
}
SOLVED:
The problem was hiarchy of cascade rules. The external style sheet where the media query resided could not over-ride the display properties set internally in the HTML document. The solution was to move the internal css to the external style sheet, then show and hide the elements in the media query. Like so:
/****LOGO*******************/
/Fix for Mobile Phones/
/***************************/
.logo_1000{display:inline-block;}/ * Show the default * /
.logo_320{display:none;} / * Hide the Mobile * /
#media screen and (max-width: 768px) { / *now we're on mobile, swap the logos * /
.logo_1000{display:none !important;}
.logo_320{display:inline-block !important;}
}
Related
I have a site with multiple menus. I have defined enteire page content inside a div with a class container and applied bootstrap css styles (margin-left:auto and margin-right:auto etc.,) to make the page centered. Now elements in one of the file must start from extreme left side of the browser. Because of the css applied for parent i could not start the element from left side. I have applied margin-left with minus pixels to solve the issue. But when the browser window is small element is not completely visible in browser because of minus value applied for margin-left.
<div class="container" style="margin-left:auto;margin-right:auto">
<div id="start_from_left" style="margin-left=-50px"> </div>
</div>
if your tags have
style=""
that takes priority over anything else.
What you could try is the !important on your css tags, but its bad practice.
eg
margin-left:1px!important;
margin-right:0px!important;
You can have additional class for your container.
.container {
margin-left: auto;
margin-right: auto;
}
.container.wide {
margin-left: 0;
margin-right: 0;
}
I running this img code for different screen resolution
<img src="http://subtlepatterns.com/patterns/grey_wash_wall.png"
data-src-400px="http://subtlepatterns.com/patterns/dark_wood.png"
alt="">
#media (min-width: 400px) {
img[data-src-400px] {
content: attr(data-src-10px, url);
}
}
http://codepen.io/anon/pen/qEqbbQ
but it give an error in my chrome, it says "invalid property value". Screenshot:
what happens and why it didnt work??
content is only applied to pseudo elements. SPEC
The '::before' and '::after' pseudo-elements are used to insert content immediately before and immediately after the content of an element (or other pseudo-element). The 'content' propety is used to specify the content to insert.
Just a remind (which may be irrelevant). <img> cannot have :before/:after pseudo elements (it cannot have decendant elements at all).
Is it still possible to add the align attribute to a HTML element to align the element itself? So that it's not set via CSS but in the element tag itself, something like this:
<div align="center"></div>
Will this still center it, or will the attribute just be ignored?
As Mike W pointed out in the comments:
The align attribute is deprecated in HTML 4, and removed in HTML 5.
Don't use it: use CSS instead.
That being said, here are some ways to center it anyway, even though you say you have more elements with that class.
Give this specific element inline style:
<div class="main" style="margin: auto;">
Be more specific in your CSS. The element is probably a child of an element that does not have any other .main babies, so you can specify this element by using the parent element in CSS:
.parent-class > .main {margin: auto;} /* If the parent has a class */
#parent-id > .main {margin: auto;} /* If the parent has an ID. This one is prefered, to avoid misunderstandings */
If the above is not the case, and there are multiple instances of .main within a single parent, you can use the nth-child selector (or first-child or last-child). For instance, if the element you want to center is the third child within the parent element, use this code.
.main:nth-child(3) {margin: auto;}
why dont you use
<div class="main" style="margin:0 auto;">
What it the best way to do that input the full width inside span3 (unresponsive design)?
Something like width: 100%;
http://jsfiddle.net/rq9FM/
Thanks.
First, when using Twitter Bootstrap I like to add a class to my <body> tag so I can override bootstrap styles if needed.
<body class="myclass">
For the CSS I would do something like this..
.myclass .well {padding:19px 0;}
//UNRESPONSIVE
.myclass .form-search input {width:108px;}
//RESPONSIVE
.myclass .form-search input {width:43%;}
The left and right padding needs to be removed from the well and from there all you should have to do is change the size of the <input>. If your span is going to be a fixed width then the unresponsive example should work for your example. If the span is going to change sizes, then you will only want the input to take up a percentage of its container.
I am trying to add a backgroung image for a "a" element, but it would only show part of the image ( so if I have Home as value, whatever space home takes that is what is shows of the image, if the value is empty it wont show anything of the image).
Despite I have setted up the width and height of the "a" element to display.
Can anybody help me?
Code.
<div style="width:1200px;height:25px;text-align:left;">
</div>
I am sure is something silly, but I cant find out what.
<a> is an inline element. Inline elements cannot have a set width and height.
You therefore need to change the display mode of the element using the CSS property display.
Use display: block; if you want your elements to be taken out of the flow of text and considered a block (ie.: stacked vertically, one block per line).
Use display: inline-block; if you want your element to behave like an inline element position wise but have block-like properties.
Note: inline-block is supported by IE6 on <a>. In IE6, inline-block display style is only supported on elements which has an inline default style.
Add display:block; to the anchors (block vs inline-block). Once you do that though, you may need to float:left; the anchors to keep them side-by-side. If you go that route, follow them all up with a clear:both; div.
a.box { float:left; width:100px; height:25px; margin:0 8px; }
.clear { clear:both; }
Foo
Foo
Foo
<div class="clear"></div>