I am trying to make the overflow of an image appear to be hidden upon a certain screen size, but I cannot find the solution of why this extra spacing appears. Here is the html an css I have so far. I am trying to do this because the image would appear too small.
Bootstrap solutions are also welcome too.
.aboutsplash img{
width: 100%;
height: auto;
margin: 0;
}
#media (max-width: 769px){
.aboutsplash img{
overflow: hidden;
width: auto;
max-height: 150px;
}
}
#media (max-width: 500px){
.aboutsplash img{
position: left;
margin: 0 0 0 -25%;
}
}
<div class="aboutsplash">
<img src="images\sunsetcrop2.jpg" alt="lbl sunset">
</div>
#media (max-width: 769px){
.aboutsplash {
overflow: hidden;
}
}
try this.
Related
No matter how I try in my CSS file, the container can't take full width in phone device.
my CSS file:
#media (max-device-width: 1024px) {
.col-sm-2{
width: 100%;
}
.container {
margin: 0 auto;
width: 100%;
}
.col-sm-10 {
width: 100%;
}
}
HTML:
<div class="container">
<h1 >Profile</h1>
</div>
Any suggestion?
You should use container-fluid class instead of container, or if would prefer you can use the sm, lg and so on suffixes , like container-sm
See the docs
Try container fluid
<div class="container-fluid">
<h1 >Profile</h1>
</div>
or add !important to #media like this
#media (max-device-width: 1024px) {
.col-sm-2{
width: 100%;
}
.container {
margin: 0 auto;
width: 100% !important;
padding: 0 !important;
}
.col-sm-10 {
width: 100% !important;
}
}
Getting what appears to be rogue margin off of a google map element. The gallery should be on the right but this margin is stopping that. Can't seem to find what's producing this margin. Even the element inspector 'Metrics'? tool shows there is no margin, but the element highlighting on the screen shows a margin that pushes to the right edge of the page
My CSS for the element.
.gallery-map {
height: 320px;
}
#media (min-width: 415px) {
.gallery-map {
height: 416px;
}
}
#media (min-width: 780px) {
.gallery-map {
height: 500px;
width: 500px;
}
}
Explicitly set margin and margin-right to 0, tried to contain it in a wrapping div (that removed the rogue margin from the map element and put it on the new wrapping element) and several other things.
A link to the branch I'm working on for this
The fix was setting a couple of inline-blocks
.gallery-map {
height: 320px;
display: inline-block;
#media (min-width: 415px) {
height: 416px;
}
#media (min-width: 780px) {
height: 500px;
width: 64.5%;
}
}
Also to get that gallery to come along side I needed to add the inline-block specifically to the media query
.gallery {
height: 318px;
overflow-y: scroll;
overflow-x: hidden;
#media (min-width: 780px) {
width: 35%;
display: inline-block;
}
}
Working on a news site and once I get to mobile, I'd like it where the image fits inside the entire width of the div....whatever that might be. The images are originally 240px in width so we are talking about bumping them up. This is what I'm currently using:
.thumb { float: left; clear: both; width: 100%; height: auto; margin: 0; }
.thumb img { max-width: 100%; max-height: 100%; }
So on my iPhone, the pic it a little bit too small since the div is 320px and the img is 240. Of course, this would change for say, landscape at 480px for example. So it needs to be flexible. Any suggestions?
You might try the following, set the image width to 100%.
.thumb {
float: left;
clear: both;
width: 100%;
height: auto;
margin: 0;
}
.thumb img {
width: 100%;
}
<div class="thumb">
<img src="http://placehold.it/200x100">
</div>
#media screen and (max-width: 480px) //place whatever the resolution you are working here{
/*enter your code here for this resolution*/
}
to learn more about
media queries
This is very simple as like this.
img {
width:100%;
}
div{
float: left; clear: both; width: 100%; height: auto; margin: 0;
}
<div>
<img src="http://www.keenthemes.com/preview/conquer/assets/plugins/jcrop/demos/demo_files/image2.jpg" />
</div>
I have this styling to an elenemt:
.width {
width: 1024px !important;
margin: 0 auto;
}
I want to disable the "width" completely OR change it to this:
#media (max-width: 1280px){
.width {
min-width: 100% !important;
}
When I run it like this, although I switch the screen resolution, it still uses the global style.
I prefer disabling it though.
Thanks.
To disable the width then do
#media (max-width: 1280px){
.width {
width: auto !important;
}
}
I would suggest removing the !important from both places
.width {
width: 1024px;
margin: 0 auto;
}
#media (max-width: 1280px){
.width {
width: auto;
}
}
In your original code, there is a missing } not sure if it is a typo or not
If you want min-width then do, assuming you removed the !important. But you can just set width: 100% and there is no need to do min-width
#media (max-width: 1280px){
.width {
width: auto;
min-width: 100%;
}
}
Check this in a browser and resize the window to see the changes... hope this help you!!!
The HTML
<div class="width">test</div>
The CSS
.width{
width:100%;
border:1px solid red;
margin:0 auto;
}
#media only screen and (min-width:1024px){
.width{
width:1024px;
border:1px solid blue;
}
}
I want to know how to size my images in #media screen and max-width:640.
My style.css:
#header-wrapper
{
position: relative;
padding: 7em 0 0;
background:url(images/fox-illustration.jpg) no-repeat center;
background-position:center;
width:auto;
height:768px;
}
My mobile.css:
#media screen and (max-width: 640px) {
header-wrapper {
width: 600px;
}
So the width is only applied to to the header-wrapper..
I also tried to give the header-wrapper in mobile.css another image
(which I sized in photoshop to mobile size).
But this didn't work either. I think because the image of the header-wrapper overwrite it in style.css?
background:url(images/fox-illustration.jpg);
background-size:600px 400px;
background-repeat:no-repeat;
Do this
First make sure your mobile.css is active.
If the second part of your code is at it is set now, you are probably missing an id tag in the css.
Try changing your
header-wrapper {
width: 600px;
}
to
#header-wrapper {
width: 600px;
}
Other than using fixed background size, you can use cover and follow the width of the #header-wrapper
#header-wrapper {
position: relative;
padding: 7em 0 0;
background:url(images/fox-illustration.jpg) no-repeat center;
background-size:cover;
width:auto;
height:768px;
}
#media screen and (max-width: 640px) {
#header-wrapper {
width: 600px;
}
}