I'm trying to set overflow-x: hidden on my react app, I have set it on the index.css body, it works on desktop screens, but not on mobile, I read the best way would be to add it to the parent element, but it doesn't seem to work on React, is there another way to do this?
The best solution is to wrap all your elements in a div for example and apply the overflow-x: hidden on it.
You can also try to use media queries and apply the overflow-x: hidden on the body of your app. For example:
#media screen and (max-width: 375px) {
body {
overflow-x: hidden;
}
}
Related
I am unable to make this HTML Form responsive. It looks fine on desktops but not on mobiles and tablets.
Here is the link to the code:
JSFiddle
I have tried removing body's overflow: hidden and white-space: nowrap; and using different types of col but it does not work. I think my stack class and padding in some places is causing the problem but I am unable to fix it.
It seems like you're making forms just with HTML. Maybe try to use bootstrap form https://getbootstrap.com/docs/4.0/components/forms/ . It will be easier to make forms responsive.
CSS media queries are the basis of responsive web design. Try something like:
div {
height: 200px;
width: 400px;
outline: 1px solid black;
}
#media screen and (max-width: 767px) {
div {
width: 100px;
}
}
<div>
Hello World
</div>
I am using wordpress to develop a website called littleboyauciton.com. I added an image at the top right of my header, and added css code:
img.sslsecure {
max-width: 40%;
min-height: auto;
}
This is displayed normally on my computer screen. But when I use chrome to simulate the ipad screen, the picture cannot be displayed on the header.
I added the css code corresponding to the screen in css, but it still has no any effect:
#media only screen and (max-width: 768px) {
img.sslsecure {
background-attachment: scroll;
}
It is doing exactly what it should do, it takes up 40% of the width of it's parent div. When you inspect the element, you can see that the parent actually almost takes up 100% of the screen width.
You can fix this by adding extra css for different screen sizes. This can be done in the theme you are using.
Or you can add extra css and write a media query yourself.
See:
https://www.w3schools.com/css/css_rwd_mediaqueries.asp
Edit.
I just saw that you've tried adding a media query. You did it right, yet you have to change the width of the element or the parent element. background-attachment: scroll; only applies to elements with a background-image. Since this is an img, it doesn't apply to this element.
Let'say, I don't want the image to be wider than 100px:
#media only screen and (max-width: 768px) {
img.sslsecure {
max-width: 100px;
}
}
I thought that I could use media queries for both mobile version and desktop version with low width, but
objects with position: fixed property behave differently, and fixing it for the mobile version messes up the desktop version.
overflow-x: hidden doesn't work for the mobile version. Yes, I have a <meta name="viewport"> tag and yes, I wrapped everything in a div inside body, and gave it the overflow-x: hidden property, but it doesn't seem to work. Even position: relative or position: fixed, don't do the trick.
Is there a reason for this?
Try the following
#media only screen and (max-width: 600px) {
.myDiv {
position: initial !important;
}
}
The !important css tag will ensure that the css is taken into account.
I want to set different css settings for a certain class for smaller devices than for bigger screens, but my css code is not working as I want it to. I mainly use Bootstrap in my project, but I am also adding some of my own css. For "normal" sized screens I am using this css code:
div.middleDiv{
max-height: 100%;
overflow: scroll;
}
And for smaller devices I want to use the following settings for middleDiv class:
#media screen and (max-width: 767px) {
div.middleDiv{
overflow: visible;
max-height: none;
}
}
My idea is to put scrollbar only on the desired div in case there is an overflow on normal devices (for example computer), but I like the default settings for smaller devices so I want to keep the default settings for those. It seems that I cannot "overwrite" the settings I have for default devices. Can anyone please help me? I will also include screenshots of what I want below. Thank you.
You can access scrollbar property by accessing: ::-webkit-scrollbar .Try below css.
CSS :
::-webkit-scrollbar {
display: none;
}
The problem seems to be the 100% height of your DIV. You could try like this:
div.middleDiv{
max-height: calc(100vh - 20px);
overflow-y: scroll;
}
Try here:
https://plnkr.co/edit/uNqhrweIBJaMsLDRQ9PX
I had a hard time to fix it. Maybe I am just very noob on css.
Basically, I want the icon to visible only in Mobile version of the site.
in above 767px I put this code to make i hidden.
.neighbourhood-img img {display:none;}
My question is, how can I make it visible in below 767px width..
Thanks!
hey check out this css
#media screen and (min-width: 768px) {
.neighbourhood-img img {display:none;}
}
#media screen and (max-width: 767px) {
.neighbourhood-img img {display:block;}
}
What you need is called media queries. Try with:
#media screen and (min-width: 768px) {
.neighbourhood-img img {display:none;}
}
It will be hidden when the width of the screen is at least 768px
You can read more about media queries here:
https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries
You can use media queries available in CSS to define the styles which meet certain conditions, in you case the condition will be screen width.
Use Css Class:
.neighbourhood-img img
{
display:block;
}
I think I understand what you're asking.
If you only want it to visible on mobile version then you could do the following:
Make a new CSS rule:
#media only screen and (max-width: 767px) {
.m-show {
display: block !important;
max-height: none !important;
overflow: visible !important;
}
}
Then wrap your icon in a div tag as below, with the styling to hide it (but make its class the m-show class):
<div style="display: none; max-height: 0; overflow: hidden" class="m-show">
Your hidden content here...
</div>
This will hide it if it isn't in that max width of 767, otherwise it will show it. Hope this makes sense. I would also suggest making that inline styling in the div tag a separate CSS class (just because I don't like inline styling).