I got media queries working perfect on second html page with this code
#media only screen and (min-device-width: 200px) and (max-device-width: 1099px) {
.snebild img {
width: 50%;
max-width: 50%;
right: 2%;
}
.title {
margin-left: 4%;
position: absolute;
top: 10%;
}
}
But on my second page im trying to change the font size so it looks good on lower resolutions but using same code just changing to correct class and p element but nothing works.
#media only screen and (min-device-width: 200px) and (max-device-width: 1099px) {
.introus p {
font-size: 8px;
}
}
This is the HTML
<div class="introus">
<h2>Main Title</h2>
<h4>Second title</h4>
<p>Text to change size on when using lower resolution such as Iphones</p>
</div>
I assume you are testing it on a desktop device and not on a mobile device.
Try to change min-device-width to min-width that should work.
Correct me if I'm wrong.
You should use min-width instead of min-device-width because the main difference between width and device-width is that device-widths don’t always match the layout viewport of said device.
Changing that parameters the code works fine
#media only screen and (min-width: 200px) and (max-width: 1099px) {
.introus p {font-size: 8px;}
}
<div class="introus">
<h2>Main Title</h2>
<h4>Second title</h4>
<p>Text to change size on when using lower resolution such as Iphones.</p>
</div>
Related
I am currently creating a website that has media queries. I already have a normal navigation however when the webpage size reduces to a mobile size, I would like for the navigation to switch to another navigation bar which I have created, which includes icons which makes it easier for mobile users
#media only screen and (min-width : 50px) {
<div class = "navbar">
<img src="Images/houseicon.png"/>
<img src="Images/educationicon.png"/>
<img s**strong text**rc="Images/contactmeicon.png"/>
</div>}
You don't need to add html to media query...
Html is part of html page
You just need to set below css with media query in your css file or in your tag.
#media only screen and (max-width : 767px) { .navbar a img{ width:50px !important; height:50px !important;}}
Use below code to show navigation properly on responsiveness mobile view.
Code::
`#media only screen and (min-width: 320px) and (max-width: 480px) {
.nav img {
height: 100px;
width: 100px;
}
} `
Note:: height: 100px; and width: 100px;
100px, is just for reference, please update height and width with your actual image size.
I want to control the size of my logo using media query.
The original width of my logo is 210px.
I want it to be 166px when the screen width is greater than 56.865em and same when it is less than this width, i.e., for mobile site.
I have written following code for this:
#media only screen and (min-width: 56.875em){
.site-branding img{
max-width: 166px;
}
}
#media only screen and (max-width: 56.875em){
.site-branding img {
max-width: 166px !important;
}
}
Only the first code block is working. Why isn't second working? (When the screen width is decreased, the width of logo becomes 210px again).
Is there any rule that you can't use both min and max media-queries to control same element?
The max-width rule won't work because it is overridden by the min-width since both have same value.
an easy approach, instead of doing 2 media queries is simply setting the logo's width in the general CSS and then apply a media query:
via non-mobile approach using the max-width
or
via the mobile first approach using min-width
Option with max-width
.logo img {
width: 210px
}
#media (max-width: 56.865em) {
.logo img {
width: 166px
}
}
<div class="logo">
<img src="//lorempixel.com/300/300">
</div>
Option with min-width
.logo img {
width: 166px
}
#media (min-width: 56.865em) {
.logo img {
width: 210px
}
}
<div class="logo">
<img src="//lorempixel.com/300/300">
</div>
UPDATE
First, I want the logo size 166px all the time.
So if you want after all is to have the logo's width at 166px all the time, meaning you want to change the current 210px to 166px
Then you don't need media queries. Assuming you are changing a custom CSS file and you can't/want to change the Base CSS file (which contains the width:210px) all you need is to be more specific.
See more about CSS specificity in MDN and in W3C Specs
/* emulating Base CSS */
.logo img {
width: 210px
}
/*being more specific */
.header .logo img {
width: 166px
}
<div class="header">
<div class="logo">
<img src="//lorempixel.com/300/300">
</div>
</div>
This drove me crazy but I found that commenting out text before #media will block the statement.
<!-- DO NOT COMMENT LIKE THIS BEFORE #media -->
/* USE THIS Comment version */
Hope it helps someone out!
I have two columns, first column has an image, second is the article. The article has a ton of "Empty spaces" I would like the height of the article to be the same height as the image so there's not visible empty space.
<article>
<div class="row">
<div class="row-sm-height">
<aside class="col-sm-6 ">
<img src="http://i0.wp.com/www.sooziq.com/wp-content/uploads/2015/11/32.jpg?resize=270%2C200" />
</aside>
<aside class="col-sm-6">
<div>
<span> Basketball</span>
<h2 id="H2_2">
What really Matters
</h2>
<span id="SPAN_2">November 12, 2015</span>
<p>
Make sure you load up on the fluids and snacks and use the washroom because these are the top 3 things to watch for in basketball! Read More
</p>
</div>
</aside>
</div>
</div>
</article>
Demo
http://codepen.io/anon/pen/WQVxor
I would like it to also be responsive, I can get the height to match using trial and error but I don't think that's the right approach.
The most simple and maybe also the best solution in your case is to make the 2 columns' parent div have the same background color as the 2 columns do so it looks like the article column has expanded.
In your css, find .row-sm-height under #media (min-width: 768px) and add the background color:
.row-sm-height {
display:table-row;
background: #f7f7f7;
}
And you just need to do nothing about specifying any height. It just adjusts to your image height.
Assuming that your images will be the same size one the same device you can set the min-height.
Add a new class to the div that is your article (not the one with "col-x").
Set the class to have a min-height of Npx.
As an example for your CSS:
div.image-article {
min-height: 250px;
}
If making it responsive you probably have your images smaller on different devices. Use a media query for these.
div.image-article {
#media (min-width: 0) {
min-height: 250px;
}
#media (min-width: #screen-xs-min) {
min-height: 250px;
}
#media (min-width: #screen-sm-min) {
min-height: 275px;
}
#media (min-width: #screen-md-min) {
min-height: 290px;
}
#media (min-width: #screen-lg-min) {
min-height: 320px;
}
}
I have a div element that must have a background image that is fixed so when you scroll the content rolls over it. My issue is that I have to set a height for that specific div element in order to see it. That is because there isn't any content in that div.
CSS
#top-banner{
background-image: url(../img/grey.jpg);
background-attachment:fixed;
height:700px;
background-repeat: no-repeat;
background-size: 100% auto;
}
HTML
<div class="container-fluid">
<div class="row" >
<div class="col-sm-12" id="top-banner"></div>
</div>
<div class="row">
<div class="col-sm-12 text-center" >
<h1 class="band-name">Lorem Ipsum</h1>
</div>
</div>
</div>
This gives me what I want for larger screens:
But as you shrink the browser, like you are on a phone or tablet, the height for that div pushes all the content down making it look unappealing:
Is there a way to not give it a specific height so the content is not pushed down on smaller screen but still have the fixed background image?
EDIT
Here is a fiddle to check out. http://jsfiddle.net/0xbfhwnt/
I reiterate: It looks fine at first but when you make the browser smaller the image shrinks like it is supposed to but the height of the div stays keeping the content below the image instead of flush with the background image div.
Have you considered something along the lines of media queries?
Here's a first iteration:
http://jsfiddle.net/0xbfhwnt/2/
#media (min-width: 400px) and (max-width: 700px) {
#top-banner{
height: 200px; }
}
#media (min-width: 200px) and (max-width: 399px) {
#top-banner{
height: 100px; }
}
UPDATE
So, using media queries, you can track the size of the main div all the way down to the smallest screen size.
In this example, all the whitespace is gone.
http://jsfiddle.net/0xbfhwnt/7/
#media (min-width: 500px) and (max-width: 800px) {
#top-banner {
height: 200px;}
}
#media (min-width: 375px) and (max-width: 499px) {
#top-banner {
height: 150px;}
}
#media (min-width: 250px) and (max-width: 374px) {
#top-banner {
height: 100px;}
}
#media (min-width: 50px) and (max-width: 249px) {
#top-banner {
height: 50px;}
}
Of course, the smaller the range between min-width and max-width, the smoother the transition would be.
Hi I'm fairly new to bootstrap and what I'm trying to achieve is to have a jumbotron on top of my page with different paragraph formatting to accommodate for a background image which takes lets say 30% of full width space.
I have offset my text by padding-left: 300px; and it looks fine on desktops but this rule also applies to a paragraph in mobile device mode resulting it being very skinny and tall.
Is there a way where I can set lets say 3 different paragraphs each showing under certain screen size?
Just use media queries:
#media screen and (max-width: 320px)
{
p{
padding-left: 0;
}
}
#media screen and (min-width: 321px) and (max-width:800px)
{
p{
padding-left: 100px;
}
}
#media screen and (min-width: 801px)
{
p{
padding-left: 300px;
}
}