hide div tag on mobile view only?
up vote
47
down vote
favorite
I'm creating a fluid layout for a site. I'm trying to hide the contents of a <div> or the whole <div> itself in the mobile view, but not the tablet and desktop view.
Here's what I've got so far...
#title_message {
clear: both;
float: left;
margin: 10px auto 5px 20px;
width: 28%;
display: none;
}
I have the display set to 'none' for the mobile layout and set as block on the tablet/desktop layouts... Is there an easier way to do that, or is that it?
css fluid-layout
add a comment |
up vote
47
down vote
favorite
I'm creating a fluid layout for a site. I'm trying to hide the contents of a <div> or the whole <div> itself in the mobile view, but not the tablet and desktop view.
Here's what I've got so far...
#title_message {
clear: both;
float: left;
margin: 10px auto 5px 20px;
width: 28%;
display: none;
}
I have the display set to 'none' for the mobile layout and set as block on the tablet/desktop layouts... Is there an easier way to do that, or is that it?
css fluid-layout
add a comment |
up vote
47
down vote
favorite
up vote
47
down vote
favorite
I'm creating a fluid layout for a site. I'm trying to hide the contents of a <div> or the whole <div> itself in the mobile view, but not the tablet and desktop view.
Here's what I've got so far...
#title_message {
clear: both;
float: left;
margin: 10px auto 5px 20px;
width: 28%;
display: none;
}
I have the display set to 'none' for the mobile layout and set as block on the tablet/desktop layouts... Is there an easier way to do that, or is that it?
css fluid-layout
I'm creating a fluid layout for a site. I'm trying to hide the contents of a <div> or the whole <div> itself in the mobile view, but not the tablet and desktop view.
Here's what I've got so far...
#title_message {
clear: both;
float: left;
margin: 10px auto 5px 20px;
width: 28%;
display: none;
}
I have the display set to 'none' for the mobile layout and set as block on the tablet/desktop layouts... Is there an easier way to do that, or is that it?
css fluid-layout
css fluid-layout
edited Aug 6 '13 at 16:04
Brad Christie
86.5k13119175
86.5k13119175
asked May 14 '13 at 18:43
KoldTurkee
362149
362149
add a comment |
add a comment |
7 Answers
7
active
oldest
votes
up vote
112
down vote
accepted
You will need two things. The first is @media screen to activate the specific code at a certain screen size, used for responsive design. The second is the use of the visibility: hidden attribute. Once the browser/screen reaches 600pixels then #title_message will become hidden.
@media screen and (max-width: 600px) {
#title_message {
visibility: hidden;
clear: both;
float: left;
margin: 10px auto 5px 20px;
width: 28%;
display: none;
}
}
EDIT: if you are using another CSS for mobile then just add the visibility: hidden; to #title_message. Hope this helps you!
That fixed it. Thanks Matt!
– KoldTurkee
May 15 '13 at 23:40
I'm glad that worked! Thanks for marking the answer as correct.
– Matt
May 16 '13 at 13:18
When you come to StackOverflow... there's always going to be a solution to your query..... Except, most of the time I seem to come across slight alternatives. ...This answer is exactly what I was looking for! ...Thank you Dude. (p.s. used for a custom mobile menu on my site amazewebs.com ...mobile menu will show when width<768px
– josh.thomson
Sep 4 '14 at 15:20
It's working for me. Have to display only mobile pages@media screen and (min-width: 700px) { .mobile-title { visibility: hidden; } } div.mobile-title h1 { text-align: center !important; font-size: 20px; font-weight: bold; padding: 5px; }
– gnganpath
Jan 23 '16 at 12:32
add a comment |
up vote
3
down vote
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) { #title_message { display: none; }}
This would be for a responsive design with a single page for an iphone screen specifically. Are you actually routing to a different mobile page?
That didn't work. It wiped out all the CSS for the mobile layout.
– KoldTurkee
May 14 '13 at 18:51
Can you provide a small sample of your css then? I'm not seeing the whole picture here but that shouldn't have wiped out your layout
– Scarecrow
May 14 '13 at 19:16
This work better, because visibility: hidden only hide the element but still there (the place remains). Instead display: none; really hide it and completely removing it.
– Angel
Aug 3 '15 at 14:41
add a comment |
up vote
2
down vote
Set the display property to none as the default, then use a media query to apply the desired styles to the div when the browser reaches a certain width. Replace 768px in the media query with whatever the minimum px value is where your div should be visible.
#title_message {
display: none;
}
@media screen and (min-width: 768px) {
#title_message {
clear: both;
display: block;
float: left;
margin: 10px auto 5px 20px;
width: 28%;
}
}
That's the wrong way round. The div won't display on browsers that don't support media queries.
– MMM
May 14 '13 at 20:43
respond.js github.com/scottjehl/Respond will solve this on older browsers that don't support media queries. Media queries are the solution for responsive sites.
– Phil Sinatra
May 15 '13 at 0:05
1
Of course they are the solution, but you're doing this the wrong way round. Unless your website is mostly used for mobile, you never build your css from the bottom up.
– MMM
May 15 '13 at 9:08
2
I don't consider mobile and desktop as separate websites. It is much easier to scale a project up as the browser gets bigger than it is to trim down as the browser gets smaller. In this case, KT is building responsive site, regardless of if it is "mostly" used for mobile or simply optimized for all browsers. A mobile first approach saves the mobile browsers from having to load additional CSS styles that never are actually applied. This approach is not the wrong way, it's simply not the way you suggest building your css.
– Phil Sinatra
May 15 '13 at 11:44
@MMM That's actually how mobile-first design is: from the bottom up.
– SepehrM
Apr 19 '16 at 19:18
|
show 2 more comments
up vote
1
down vote
You can be guided by this example. On your css file:
.deskContent {
background-image: url(../img/big-pic.png);
width: 100%;
height: 400px;
background-repeat: no-repeat;
background-size: contain;
}
.phoneContent {
background-image: url(../img/small-pic.png);
width: 100%;
height: 100px;
background-repeat: no-repeat;
background-size: contain;
}
@media all and (max-width: 959px) {
.deskContent {display:block;}
.phoneContent {display:none;}
}
@media all and (max-width: 479px) {
.deskContent {display:none;}
.phoneContent {display:block;}
}
On your html file:
<div class="deskContent">Content for desktop</div>
<div class="phoneContent">Content for mobile</div>
add a comment |
up vote
1
down vote
The solution given didn't work for me on the desktop, it just showed both divs, although the mobile only showed the mobile div. So I did a little search and found the min-width option. I updated my code to the following and it works fine now :)
CSS:
@media all and (min-width: 480px) {
.deskContent {display:block;}
.phoneContent {display:none;}
}
@media all and (max-width: 479px) {
.deskContent {display:none;}
.phoneContent {display:block;}
}
HTML:
<div class="deskContent">Content for desktop</div>
<div class="phoneContent">Content for mobile</div>
add a comment |
up vote
0
down vote
try this
@media handheld{
#title_message { display: none; }
}
add a comment |
up vote
0
down vote
i just switched positions and worked for me (showing only mobile )
<style>
.MobileContent {
display: none;
text-align:center;
}
@media screen and (max-width: 768px) {
.MobileContent {
display:block;
}
}
</style>
<div class="MobileContent"> Something </div>add a comment |
7 Answers
7
active
oldest
votes
7 Answers
7
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
112
down vote
accepted
You will need two things. The first is @media screen to activate the specific code at a certain screen size, used for responsive design. The second is the use of the visibility: hidden attribute. Once the browser/screen reaches 600pixels then #title_message will become hidden.
@media screen and (max-width: 600px) {
#title_message {
visibility: hidden;
clear: both;
float: left;
margin: 10px auto 5px 20px;
width: 28%;
display: none;
}
}
EDIT: if you are using another CSS for mobile then just add the visibility: hidden; to #title_message. Hope this helps you!
That fixed it. Thanks Matt!
– KoldTurkee
May 15 '13 at 23:40
I'm glad that worked! Thanks for marking the answer as correct.
– Matt
May 16 '13 at 13:18
When you come to StackOverflow... there's always going to be a solution to your query..... Except, most of the time I seem to come across slight alternatives. ...This answer is exactly what I was looking for! ...Thank you Dude. (p.s. used for a custom mobile menu on my site amazewebs.com ...mobile menu will show when width<768px
– josh.thomson
Sep 4 '14 at 15:20
It's working for me. Have to display only mobile pages@media screen and (min-width: 700px) { .mobile-title { visibility: hidden; } } div.mobile-title h1 { text-align: center !important; font-size: 20px; font-weight: bold; padding: 5px; }
– gnganpath
Jan 23 '16 at 12:32
add a comment |
up vote
112
down vote
accepted
You will need two things. The first is @media screen to activate the specific code at a certain screen size, used for responsive design. The second is the use of the visibility: hidden attribute. Once the browser/screen reaches 600pixels then #title_message will become hidden.
@media screen and (max-width: 600px) {
#title_message {
visibility: hidden;
clear: both;
float: left;
margin: 10px auto 5px 20px;
width: 28%;
display: none;
}
}
EDIT: if you are using another CSS for mobile then just add the visibility: hidden; to #title_message. Hope this helps you!
That fixed it. Thanks Matt!
– KoldTurkee
May 15 '13 at 23:40
I'm glad that worked! Thanks for marking the answer as correct.
– Matt
May 16 '13 at 13:18
When you come to StackOverflow... there's always going to be a solution to your query..... Except, most of the time I seem to come across slight alternatives. ...This answer is exactly what I was looking for! ...Thank you Dude. (p.s. used for a custom mobile menu on my site amazewebs.com ...mobile menu will show when width<768px
– josh.thomson
Sep 4 '14 at 15:20
It's working for me. Have to display only mobile pages@media screen and (min-width: 700px) { .mobile-title { visibility: hidden; } } div.mobile-title h1 { text-align: center !important; font-size: 20px; font-weight: bold; padding: 5px; }
– gnganpath
Jan 23 '16 at 12:32
add a comment |
up vote
112
down vote
accepted
up vote
112
down vote
accepted
You will need two things. The first is @media screen to activate the specific code at a certain screen size, used for responsive design. The second is the use of the visibility: hidden attribute. Once the browser/screen reaches 600pixels then #title_message will become hidden.
@media screen and (max-width: 600px) {
#title_message {
visibility: hidden;
clear: both;
float: left;
margin: 10px auto 5px 20px;
width: 28%;
display: none;
}
}
EDIT: if you are using another CSS for mobile then just add the visibility: hidden; to #title_message. Hope this helps you!
You will need two things. The first is @media screen to activate the specific code at a certain screen size, used for responsive design. The second is the use of the visibility: hidden attribute. Once the browser/screen reaches 600pixels then #title_message will become hidden.
@media screen and (max-width: 600px) {
#title_message {
visibility: hidden;
clear: both;
float: left;
margin: 10px auto 5px 20px;
width: 28%;
display: none;
}
}
EDIT: if you are using another CSS for mobile then just add the visibility: hidden; to #title_message. Hope this helps you!
edited Feb 1 at 5:22
Jason Aller
3,04192831
3,04192831
answered May 14 '13 at 21:28
Matt
1,5231920
1,5231920
That fixed it. Thanks Matt!
– KoldTurkee
May 15 '13 at 23:40
I'm glad that worked! Thanks for marking the answer as correct.
– Matt
May 16 '13 at 13:18
When you come to StackOverflow... there's always going to be a solution to your query..... Except, most of the time I seem to come across slight alternatives. ...This answer is exactly what I was looking for! ...Thank you Dude. (p.s. used for a custom mobile menu on my site amazewebs.com ...mobile menu will show when width<768px
– josh.thomson
Sep 4 '14 at 15:20
It's working for me. Have to display only mobile pages@media screen and (min-width: 700px) { .mobile-title { visibility: hidden; } } div.mobile-title h1 { text-align: center !important; font-size: 20px; font-weight: bold; padding: 5px; }
– gnganpath
Jan 23 '16 at 12:32
add a comment |
That fixed it. Thanks Matt!
– KoldTurkee
May 15 '13 at 23:40
I'm glad that worked! Thanks for marking the answer as correct.
– Matt
May 16 '13 at 13:18
When you come to StackOverflow... there's always going to be a solution to your query..... Except, most of the time I seem to come across slight alternatives. ...This answer is exactly what I was looking for! ...Thank you Dude. (p.s. used for a custom mobile menu on my site amazewebs.com ...mobile menu will show when width<768px
– josh.thomson
Sep 4 '14 at 15:20
It's working for me. Have to display only mobile pages@media screen and (min-width: 700px) { .mobile-title { visibility: hidden; } } div.mobile-title h1 { text-align: center !important; font-size: 20px; font-weight: bold; padding: 5px; }
– gnganpath
Jan 23 '16 at 12:32
That fixed it. Thanks Matt!
– KoldTurkee
May 15 '13 at 23:40
That fixed it. Thanks Matt!
– KoldTurkee
May 15 '13 at 23:40
I'm glad that worked! Thanks for marking the answer as correct.
– Matt
May 16 '13 at 13:18
I'm glad that worked! Thanks for marking the answer as correct.
– Matt
May 16 '13 at 13:18
When you come to StackOverflow... there's always going to be a solution to your query..... Except, most of the time I seem to come across slight alternatives. ...This answer is exactly what I was looking for! ...Thank you Dude. (p.s. used for a custom mobile menu on my site amazewebs.com ...mobile menu will show when width<768px
– josh.thomson
Sep 4 '14 at 15:20
When you come to StackOverflow... there's always going to be a solution to your query..... Except, most of the time I seem to come across slight alternatives. ...This answer is exactly what I was looking for! ...Thank you Dude. (p.s. used for a custom mobile menu on my site amazewebs.com ...mobile menu will show when width<768px
– josh.thomson
Sep 4 '14 at 15:20
It's working for me. Have to display only mobile pages@media screen and (min-width: 700px) { .mobile-title { visibility: hidden; } } div.mobile-title h1 { text-align: center !important; font-size: 20px; font-weight: bold; padding: 5px; }
– gnganpath
Jan 23 '16 at 12:32
It's working for me. Have to display only mobile pages@media screen and (min-width: 700px) { .mobile-title { visibility: hidden; } } div.mobile-title h1 { text-align: center !important; font-size: 20px; font-weight: bold; padding: 5px; }
– gnganpath
Jan 23 '16 at 12:32
add a comment |
up vote
3
down vote
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) { #title_message { display: none; }}
This would be for a responsive design with a single page for an iphone screen specifically. Are you actually routing to a different mobile page?
That didn't work. It wiped out all the CSS for the mobile layout.
– KoldTurkee
May 14 '13 at 18:51
Can you provide a small sample of your css then? I'm not seeing the whole picture here but that shouldn't have wiped out your layout
– Scarecrow
May 14 '13 at 19:16
This work better, because visibility: hidden only hide the element but still there (the place remains). Instead display: none; really hide it and completely removing it.
– Angel
Aug 3 '15 at 14:41
add a comment |
up vote
3
down vote
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) { #title_message { display: none; }}
This would be for a responsive design with a single page for an iphone screen specifically. Are you actually routing to a different mobile page?
That didn't work. It wiped out all the CSS for the mobile layout.
– KoldTurkee
May 14 '13 at 18:51
Can you provide a small sample of your css then? I'm not seeing the whole picture here but that shouldn't have wiped out your layout
– Scarecrow
May 14 '13 at 19:16
This work better, because visibility: hidden only hide the element but still there (the place remains). Instead display: none; really hide it and completely removing it.
– Angel
Aug 3 '15 at 14:41
add a comment |
up vote
3
down vote
up vote
3
down vote
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) { #title_message { display: none; }}
This would be for a responsive design with a single page for an iphone screen specifically. Are you actually routing to a different mobile page?
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) { #title_message { display: none; }}
This would be for a responsive design with a single page for an iphone screen specifically. Are you actually routing to a different mobile page?
edited Aug 13 '16 at 5:10
Munawir
2,80782237
2,80782237
answered May 14 '13 at 18:46
Scarecrow
1257
1257
That didn't work. It wiped out all the CSS for the mobile layout.
– KoldTurkee
May 14 '13 at 18:51
Can you provide a small sample of your css then? I'm not seeing the whole picture here but that shouldn't have wiped out your layout
– Scarecrow
May 14 '13 at 19:16
This work better, because visibility: hidden only hide the element but still there (the place remains). Instead display: none; really hide it and completely removing it.
– Angel
Aug 3 '15 at 14:41
add a comment |
That didn't work. It wiped out all the CSS for the mobile layout.
– KoldTurkee
May 14 '13 at 18:51
Can you provide a small sample of your css then? I'm not seeing the whole picture here but that shouldn't have wiped out your layout
– Scarecrow
May 14 '13 at 19:16
This work better, because visibility: hidden only hide the element but still there (the place remains). Instead display: none; really hide it and completely removing it.
– Angel
Aug 3 '15 at 14:41
That didn't work. It wiped out all the CSS for the mobile layout.
– KoldTurkee
May 14 '13 at 18:51
That didn't work. It wiped out all the CSS for the mobile layout.
– KoldTurkee
May 14 '13 at 18:51
Can you provide a small sample of your css then? I'm not seeing the whole picture here but that shouldn't have wiped out your layout
– Scarecrow
May 14 '13 at 19:16
Can you provide a small sample of your css then? I'm not seeing the whole picture here but that shouldn't have wiped out your layout
– Scarecrow
May 14 '13 at 19:16
This work better, because visibility: hidden only hide the element but still there (the place remains). Instead display: none; really hide it and completely removing it.
– Angel
Aug 3 '15 at 14:41
This work better, because visibility: hidden only hide the element but still there (the place remains). Instead display: none; really hide it and completely removing it.
– Angel
Aug 3 '15 at 14:41
add a comment |
up vote
2
down vote
Set the display property to none as the default, then use a media query to apply the desired styles to the div when the browser reaches a certain width. Replace 768px in the media query with whatever the minimum px value is where your div should be visible.
#title_message {
display: none;
}
@media screen and (min-width: 768px) {
#title_message {
clear: both;
display: block;
float: left;
margin: 10px auto 5px 20px;
width: 28%;
}
}
That's the wrong way round. The div won't display on browsers that don't support media queries.
– MMM
May 14 '13 at 20:43
respond.js github.com/scottjehl/Respond will solve this on older browsers that don't support media queries. Media queries are the solution for responsive sites.
– Phil Sinatra
May 15 '13 at 0:05
1
Of course they are the solution, but you're doing this the wrong way round. Unless your website is mostly used for mobile, you never build your css from the bottom up.
– MMM
May 15 '13 at 9:08
2
I don't consider mobile and desktop as separate websites. It is much easier to scale a project up as the browser gets bigger than it is to trim down as the browser gets smaller. In this case, KT is building responsive site, regardless of if it is "mostly" used for mobile or simply optimized for all browsers. A mobile first approach saves the mobile browsers from having to load additional CSS styles that never are actually applied. This approach is not the wrong way, it's simply not the way you suggest building your css.
– Phil Sinatra
May 15 '13 at 11:44
@MMM That's actually how mobile-first design is: from the bottom up.
– SepehrM
Apr 19 '16 at 19:18
|
show 2 more comments
up vote
2
down vote
Set the display property to none as the default, then use a media query to apply the desired styles to the div when the browser reaches a certain width. Replace 768px in the media query with whatever the minimum px value is where your div should be visible.
#title_message {
display: none;
}
@media screen and (min-width: 768px) {
#title_message {
clear: both;
display: block;
float: left;
margin: 10px auto 5px 20px;
width: 28%;
}
}
That's the wrong way round. The div won't display on browsers that don't support media queries.
– MMM
May 14 '13 at 20:43
respond.js github.com/scottjehl/Respond will solve this on older browsers that don't support media queries. Media queries are the solution for responsive sites.
– Phil Sinatra
May 15 '13 at 0:05
1
Of course they are the solution, but you're doing this the wrong way round. Unless your website is mostly used for mobile, you never build your css from the bottom up.
– MMM
May 15 '13 at 9:08
2
I don't consider mobile and desktop as separate websites. It is much easier to scale a project up as the browser gets bigger than it is to trim down as the browser gets smaller. In this case, KT is building responsive site, regardless of if it is "mostly" used for mobile or simply optimized for all browsers. A mobile first approach saves the mobile browsers from having to load additional CSS styles that never are actually applied. This approach is not the wrong way, it's simply not the way you suggest building your css.
– Phil Sinatra
May 15 '13 at 11:44
@MMM That's actually how mobile-first design is: from the bottom up.
– SepehrM
Apr 19 '16 at 19:18
|
show 2 more comments
up vote
2
down vote
up vote
2
down vote
Set the display property to none as the default, then use a media query to apply the desired styles to the div when the browser reaches a certain width. Replace 768px in the media query with whatever the minimum px value is where your div should be visible.
#title_message {
display: none;
}
@media screen and (min-width: 768px) {
#title_message {
clear: both;
display: block;
float: left;
margin: 10px auto 5px 20px;
width: 28%;
}
}
Set the display property to none as the default, then use a media query to apply the desired styles to the div when the browser reaches a certain width. Replace 768px in the media query with whatever the minimum px value is where your div should be visible.
#title_message {
display: none;
}
@media screen and (min-width: 768px) {
#title_message {
clear: both;
display: block;
float: left;
margin: 10px auto 5px 20px;
width: 28%;
}
}
answered May 14 '13 at 20:27
Phil Sinatra
199111
199111
That's the wrong way round. The div won't display on browsers that don't support media queries.
– MMM
May 14 '13 at 20:43
respond.js github.com/scottjehl/Respond will solve this on older browsers that don't support media queries. Media queries are the solution for responsive sites.
– Phil Sinatra
May 15 '13 at 0:05
1
Of course they are the solution, but you're doing this the wrong way round. Unless your website is mostly used for mobile, you never build your css from the bottom up.
– MMM
May 15 '13 at 9:08
2
I don't consider mobile and desktop as separate websites. It is much easier to scale a project up as the browser gets bigger than it is to trim down as the browser gets smaller. In this case, KT is building responsive site, regardless of if it is "mostly" used for mobile or simply optimized for all browsers. A mobile first approach saves the mobile browsers from having to load additional CSS styles that never are actually applied. This approach is not the wrong way, it's simply not the way you suggest building your css.
– Phil Sinatra
May 15 '13 at 11:44
@MMM That's actually how mobile-first design is: from the bottom up.
– SepehrM
Apr 19 '16 at 19:18
|
show 2 more comments
That's the wrong way round. The div won't display on browsers that don't support media queries.
– MMM
May 14 '13 at 20:43
respond.js github.com/scottjehl/Respond will solve this on older browsers that don't support media queries. Media queries are the solution for responsive sites.
– Phil Sinatra
May 15 '13 at 0:05
1
Of course they are the solution, but you're doing this the wrong way round. Unless your website is mostly used for mobile, you never build your css from the bottom up.
– MMM
May 15 '13 at 9:08
2
I don't consider mobile and desktop as separate websites. It is much easier to scale a project up as the browser gets bigger than it is to trim down as the browser gets smaller. In this case, KT is building responsive site, regardless of if it is "mostly" used for mobile or simply optimized for all browsers. A mobile first approach saves the mobile browsers from having to load additional CSS styles that never are actually applied. This approach is not the wrong way, it's simply not the way you suggest building your css.
– Phil Sinatra
May 15 '13 at 11:44
@MMM That's actually how mobile-first design is: from the bottom up.
– SepehrM
Apr 19 '16 at 19:18
That's the wrong way round. The div won't display on browsers that don't support media queries.
– MMM
May 14 '13 at 20:43
That's the wrong way round. The div won't display on browsers that don't support media queries.
– MMM
May 14 '13 at 20:43
respond.js github.com/scottjehl/Respond will solve this on older browsers that don't support media queries. Media queries are the solution for responsive sites.
– Phil Sinatra
May 15 '13 at 0:05
respond.js github.com/scottjehl/Respond will solve this on older browsers that don't support media queries. Media queries are the solution for responsive sites.
– Phil Sinatra
May 15 '13 at 0:05
1
1
Of course they are the solution, but you're doing this the wrong way round. Unless your website is mostly used for mobile, you never build your css from the bottom up.
– MMM
May 15 '13 at 9:08
Of course they are the solution, but you're doing this the wrong way round. Unless your website is mostly used for mobile, you never build your css from the bottom up.
– MMM
May 15 '13 at 9:08
2
2
I don't consider mobile and desktop as separate websites. It is much easier to scale a project up as the browser gets bigger than it is to trim down as the browser gets smaller. In this case, KT is building responsive site, regardless of if it is "mostly" used for mobile or simply optimized for all browsers. A mobile first approach saves the mobile browsers from having to load additional CSS styles that never are actually applied. This approach is not the wrong way, it's simply not the way you suggest building your css.
– Phil Sinatra
May 15 '13 at 11:44
I don't consider mobile and desktop as separate websites. It is much easier to scale a project up as the browser gets bigger than it is to trim down as the browser gets smaller. In this case, KT is building responsive site, regardless of if it is "mostly" used for mobile or simply optimized for all browsers. A mobile first approach saves the mobile browsers from having to load additional CSS styles that never are actually applied. This approach is not the wrong way, it's simply not the way you suggest building your css.
– Phil Sinatra
May 15 '13 at 11:44
@MMM That's actually how mobile-first design is: from the bottom up.
– SepehrM
Apr 19 '16 at 19:18
@MMM That's actually how mobile-first design is: from the bottom up.
– SepehrM
Apr 19 '16 at 19:18
|
show 2 more comments
up vote
1
down vote
You can be guided by this example. On your css file:
.deskContent {
background-image: url(../img/big-pic.png);
width: 100%;
height: 400px;
background-repeat: no-repeat;
background-size: contain;
}
.phoneContent {
background-image: url(../img/small-pic.png);
width: 100%;
height: 100px;
background-repeat: no-repeat;
background-size: contain;
}
@media all and (max-width: 959px) {
.deskContent {display:block;}
.phoneContent {display:none;}
}
@media all and (max-width: 479px) {
.deskContent {display:none;}
.phoneContent {display:block;}
}
On your html file:
<div class="deskContent">Content for desktop</div>
<div class="phoneContent">Content for mobile</div>
add a comment |
up vote
1
down vote
You can be guided by this example. On your css file:
.deskContent {
background-image: url(../img/big-pic.png);
width: 100%;
height: 400px;
background-repeat: no-repeat;
background-size: contain;
}
.phoneContent {
background-image: url(../img/small-pic.png);
width: 100%;
height: 100px;
background-repeat: no-repeat;
background-size: contain;
}
@media all and (max-width: 959px) {
.deskContent {display:block;}
.phoneContent {display:none;}
}
@media all and (max-width: 479px) {
.deskContent {display:none;}
.phoneContent {display:block;}
}
On your html file:
<div class="deskContent">Content for desktop</div>
<div class="phoneContent">Content for mobile</div>
add a comment |
up vote
1
down vote
up vote
1
down vote
You can be guided by this example. On your css file:
.deskContent {
background-image: url(../img/big-pic.png);
width: 100%;
height: 400px;
background-repeat: no-repeat;
background-size: contain;
}
.phoneContent {
background-image: url(../img/small-pic.png);
width: 100%;
height: 100px;
background-repeat: no-repeat;
background-size: contain;
}
@media all and (max-width: 959px) {
.deskContent {display:block;}
.phoneContent {display:none;}
}
@media all and (max-width: 479px) {
.deskContent {display:none;}
.phoneContent {display:block;}
}
On your html file:
<div class="deskContent">Content for desktop</div>
<div class="phoneContent">Content for mobile</div>
You can be guided by this example. On your css file:
.deskContent {
background-image: url(../img/big-pic.png);
width: 100%;
height: 400px;
background-repeat: no-repeat;
background-size: contain;
}
.phoneContent {
background-image: url(../img/small-pic.png);
width: 100%;
height: 100px;
background-repeat: no-repeat;
background-size: contain;
}
@media all and (max-width: 959px) {
.deskContent {display:block;}
.phoneContent {display:none;}
}
@media all and (max-width: 479px) {
.deskContent {display:none;}
.phoneContent {display:block;}
}
On your html file:
<div class="deskContent">Content for desktop</div>
<div class="phoneContent">Content for mobile</div>
answered Apr 19 '17 at 21:20
gras
1,2821217
1,2821217
add a comment |
add a comment |
up vote
1
down vote
The solution given didn't work for me on the desktop, it just showed both divs, although the mobile only showed the mobile div. So I did a little search and found the min-width option. I updated my code to the following and it works fine now :)
CSS:
@media all and (min-width: 480px) {
.deskContent {display:block;}
.phoneContent {display:none;}
}
@media all and (max-width: 479px) {
.deskContent {display:none;}
.phoneContent {display:block;}
}
HTML:
<div class="deskContent">Content for desktop</div>
<div class="phoneContent">Content for mobile</div>
add a comment |
up vote
1
down vote
The solution given didn't work for me on the desktop, it just showed both divs, although the mobile only showed the mobile div. So I did a little search and found the min-width option. I updated my code to the following and it works fine now :)
CSS:
@media all and (min-width: 480px) {
.deskContent {display:block;}
.phoneContent {display:none;}
}
@media all and (max-width: 479px) {
.deskContent {display:none;}
.phoneContent {display:block;}
}
HTML:
<div class="deskContent">Content for desktop</div>
<div class="phoneContent">Content for mobile</div>
add a comment |
up vote
1
down vote
up vote
1
down vote
The solution given didn't work for me on the desktop, it just showed both divs, although the mobile only showed the mobile div. So I did a little search and found the min-width option. I updated my code to the following and it works fine now :)
CSS:
@media all and (min-width: 480px) {
.deskContent {display:block;}
.phoneContent {display:none;}
}
@media all and (max-width: 479px) {
.deskContent {display:none;}
.phoneContent {display:block;}
}
HTML:
<div class="deskContent">Content for desktop</div>
<div class="phoneContent">Content for mobile</div>
The solution given didn't work for me on the desktop, it just showed both divs, although the mobile only showed the mobile div. So I did a little search and found the min-width option. I updated my code to the following and it works fine now :)
CSS:
@media all and (min-width: 480px) {
.deskContent {display:block;}
.phoneContent {display:none;}
}
@media all and (max-width: 479px) {
.deskContent {display:none;}
.phoneContent {display:block;}
}
HTML:
<div class="deskContent">Content for desktop</div>
<div class="phoneContent">Content for mobile</div>
answered Aug 2 '17 at 22:15
Steve Hall
135
135
add a comment |
add a comment |
up vote
0
down vote
try this
@media handheld{
#title_message { display: none; }
}
add a comment |
up vote
0
down vote
try this
@media handheld{
#title_message { display: none; }
}
add a comment |
up vote
0
down vote
up vote
0
down vote
try this
@media handheld{
#title_message { display: none; }
}
try this
@media handheld{
#title_message { display: none; }
}
answered May 14 '13 at 21:20
Alejandro Ruiz Arias
121111
121111
add a comment |
add a comment |
up vote
0
down vote
i just switched positions and worked for me (showing only mobile )
<style>
.MobileContent {
display: none;
text-align:center;
}
@media screen and (max-width: 768px) {
.MobileContent {
display:block;
}
}
</style>
<div class="MobileContent"> Something </div>add a comment |
up vote
0
down vote
i just switched positions and worked for me (showing only mobile )
<style>
.MobileContent {
display: none;
text-align:center;
}
@media screen and (max-width: 768px) {
.MobileContent {
display:block;
}
}
</style>
<div class="MobileContent"> Something </div>add a comment |
up vote
0
down vote
up vote
0
down vote
i just switched positions and worked for me (showing only mobile )
<style>
.MobileContent {
display: none;
text-align:center;
}
@media screen and (max-width: 768px) {
.MobileContent {
display:block;
}
}
</style>
<div class="MobileContent"> Something </div>i just switched positions and worked for me (showing only mobile )
<style>
.MobileContent {
display: none;
text-align:center;
}
@media screen and (max-width: 768px) {
.MobileContent {
display:block;
}
}
</style>
<div class="MobileContent"> Something </div><style>
.MobileContent {
display: none;
text-align:center;
}
@media screen and (max-width: 768px) {
.MobileContent {
display:block;
}
}
</style>
<div class="MobileContent"> Something </div><style>
.MobileContent {
display: none;
text-align:center;
}
@media screen and (max-width: 768px) {
.MobileContent {
display:block;
}
}
</style>
<div class="MobileContent"> Something </div>answered Mar 15 at 23:07
Carlos franco
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f16550485%2fhide-div-tag-on-mobile-view-only%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown