Images only in this particular row of my webpage are disappearing when displayed on the iPad mini (768x1024) and the Galaxy Tablet (800x1280). Other content in the section remain visible. Why would this be happening? Is there a quirk with the mobile devices or perhaps an error in my CSS? (On the rest of the page both images and text are displaying properly on mobile devices.)
The (barebones) code for the row is:
<div class="row" id="advertcontainer">
<h2 class="wow fadeInUp adjust" data-wow-delay="0.2s" style="max-width: 100%;display: block;">What's On across the Lakeside Group</h2>
<div class="grid_4 wow fadeIn" data-wow-delay="0.2s">
<div class="imagediv">
<a href=""><img src="image.jpg" alt="image test" />
<div class="transparent_ribbon"></div>
<div class="overlayeventname">Text here</div>
<div class="overlayeventplace">More text here</div>
</a>
</div>
</div>
</div><!-- /row /advertcontainer -->
In my CSS I've set a breakpoint of 768 to hide this entire row:
#media (min-width: 320px) and (max-width: 768px) {
#advertcontainer {
display: none;
}
}
My complete stylesheet can be viewed at http://www.lakesidesurrey.co.uk/css/style.css
This is what it should look like
But this is what is being displayed on the iPad mini and the Galaxy Tablet
You have this rule in your CSS:
.imagediv img {
position: absolute;
z-index: -1;
}
This will move those images behind all regular layers and change their position to the upper left corner of their containers (if they have position: relative). If those parent elements are not transparent, the images will remain invisible.
Plus, if the image size isn't set within the img tag, the size will be 0x0 since there is no defined widthand height --> they'll be invisible...
Related
I have a web application layout like this, styled with Bootstrap:
------------------------
| Header |
------------------------
| Display Area |
------------------------
The Header is a collection of control elements (mostly buttons) and therefore almost of same height.
The Display Area contains the following:
<div class="row">
<div class="col">
<img class="img-fluid" src="http://localhost/api/currentImage" />
</div>
</div>
http://localhost/api/currentImage returns an image. The image's size always differs: sometimes the width is bigger than height, sometimes vice versa.
Now I'd like to scale the image in that way that it uses as much as possible of the available Display without "overflowing". By overflowing, I mean that there is never a need to show a horizontal or vertical scroll bar because the image is too wide or too high. Right now, <img class="img-fluid" ... only scales the width correctly.
How can I achieve this using Bootstrap/CSS?
Bootstrap will let you resize images with its img-fluid class, but if you need to make the image cover the entire space you would have to write your own CSS, you could make use of the object-fit property to set the image to fill the container, while maintaining its aspect ratio and clipping off if necessary;
As you can see in the example below, the image is narrow, but it will fill the entire container even if it has to expand to do so.
EDIT: Included two more examples with fill and contain so you can see how their behavior changes.
header {
border: 1px solid red;
padding: 10px;
}
section {
border: 1px solid blue;
}
img {
height: calc(100vh - 20px);
width: 100%;
/* This is just to remove a blank space at the bottom of the image */
display: block;
}
img.cover {
object-fit: cover;
}
img.contain {
object-fit: contain;
}
img.fill {
object-fit: fill;
}
<header>
This is a header
</header>
<section>
<img class="cover" src="https://via.placeholder.com/200x700" />
</section>
<section>
<img class="contain" src="https://via.placeholder.com/200x700" />
</section>
<section>
<img class="fill" src="https://via.placeholder.com/200x700" />
</section>
Bootstrap has a predefined classes for responsive image. Check the following class,
.img-responsive Makes an image responsive (will scale nicely to the parent element)
<div class="row">
<div class="col">
<img class="img-fluid img-responsive" src="http://localhost/api/currentImage" />
</div>
</div>
`
So I have the class:
awpcp-subtitle.
Within this I want to target a child element, which I can with:
#media (max-width: 1920px) and (min-width: 769px) {
.awpcp-subtitle:nth-of-type(1) {
margin-top: 440px!Important;
}
}
This enables me to move it up and down. But I want to align the text which floats left at the moment and:
#media (max-width: 1920px) and (min-width: 769px) {
.awpcp-subtitle:nth-of-type(1) {
text-align: center!Important;
}
}
Doesn't work.
Any ideas?
Here is html:
<div class="awpcp-subtitle">Contact Information</div>
<a href="https://adsler.co.uk/wp-user-test-dashboard-
2/awpcp-reply-to-ad/21/old-goriot-balzac/">Email
admin</a><a href="tel:<br/><label>Phone:</label>
07576335122"><div class="phone"><br/><label>Phone:
</label> 07576335122</div> </a>
<a href="http://maps.google.com/?q=:<br/>.
<label>Location:</label> Westminster, London, UK"><div
class="location"><br/><label>Location:</label>
Westminster, London, UK</div></a>
<div class="visit-website"><Visit Website:</div>
</div>
<div class="showawpcpadpage"><label>Price:</label>
<strong>£ 0.99</strong></div>
<div class="fixfloat"></div>
<div class="showawpcpadpage">
<div class="awpcp-subtitle">More Information</div>
Right so basically after looking at the pages code via the link you provided, its a simple case of rearranging the order of your HTML elements.
in the section div section - showawpcpadpage you need to move the awpcp-subtitle [Contact Information] to the top, instead of being under the image + links.
<div class="showawpcpadpage">
<div class="awpcp-subtitle">Contact Information</div>
<div class="awpcp-ad-primary-image">
<a class="awpcp-listing-primary-image-thickbox-link thickbox thumbnail" href="https://adsler.co.uk/wp-content/uploads/awpcp/images/19808423-2b60d824-large.jpg" rel="awpcp-gallery-21">
<img class="thumbshow" src="https://adsler.co.uk/wp-content/uploads/awpcp/thumbs/19808423-2b60d824-primary.jpg" alt="Thumbnail for the listing's main image" width="200" height="200">
</a>
that's what your HTML flow should look like.
The layout of your HTML is important. So if for example, if your header is at the top of the page, the HTML for the header should also be at the top of the page, not several elements down.
I'm creating a form using responsive design using Bootstrap. My goal is to make such input that would be the slider type on mobile devices, and the text type on medium devices and bigger.
For that reason I'm using different classes in two divs to show and hide content depending on the device screen width (e.g. hidden-xs, hidden-sm, hidden-md, hidden-lg).
<div class="form-group hidden-sm hidden-md hidden-lg">
<!-- input type slider for mobile devices -->
</div>
<div class="form-group hidden-xs">
<!-- input type text for wider screen devices -->
</div>
I also have a #media rule in my css file:
#media (min-width: 768px) {
.sm-view {
display: none;
}
}
#media (max-width: 767px) {
.lg-view {
display: none;
}
}
It works as I expected, except on the boundary width value of 767px, on this width both divs are visible:
As only I increase the width value to 768px the slider hides, and when I set the width value to 766px the input field hides.
What I'm doing wrong?
UPD Here is working example: https://jsfiddle.net/rnurxbw9/1/
Here the window width would be different, but you can see it on the screenshot:
You're not letting us know which Bootstrap version you're using. I would look at their documentation v4 documentation or v3 documentation
If you're using bootstrap you shouldn't need to set any css manually. Try adding the visible-sm class to the one you're trying to show on larger devices.
<div class="form-group hidden-sm hidden-md hidden-lg">
<!-- input type slider for mobile devices -->
</div>
<div class="form-group hidden-xs visible-sm">
<!-- input type text for wider screen devices -->
</div>
Trying to create a responsive grid which supports mobile screens. When using jQuery mobile ui-responsive grid, the column wraps and behaves like rows(one below one) even-though the first row has space accommodate second column. If I test the same in Tablet size screens, things works fine. Where I am wrong or this is how it behaves ?
The code I used is
<div class="ui-grid-a ui-responsive">
<div class="ui-block-a">
<a href="#" id="link_frgt_pswd" data-inline="true" >Forgot Password ?</a>
</div>
<div class="ui-block-b">
Login
</div>
</div>
<div class="ui-grid-a ui-responsive">
<div class="ui-block-a">
<h3>For Member </h3>
</div>
<div class="ui-block-b">
<a href="#" id="link_unlock_acc" data-inline="true" >Unlock Account</a>
</div>
</div>
<div class="ui-grid-a ui-responsive">
<div class="ui-block-a">
<h3>For Provider </h3>
</div>
<div class="ui-block-b">
Register
</div>
</div>
I even tried to reduce the width of columns with css .ui-grid-a .ui-block-a { width: 30% } .ui-grid-a .ui-block-b { width: 30% }. it reduces the width but still ui-block-b remains in the next line.
The ui-responsive class in jQM adds a CSS media query for a max-width of 560px. So any time the screen is less than 560px, the columns are stacked. If you want your own custom break point, instead of ui-responsive, make your own class name and set your desired break point.
For example, if you want the stacking to happen only when screen width is below 300px:
<div class="ui-grid-a my-breakpoint">...</div>
#media all and (max-width: 300px) {
.my-breakpoint .ui-block-a,
.my-breakpoint .ui-block-b,
.my-breakpoint .ui-block-c,
.my-breakpoint .ui-block-d,
.my-breakpoint .ui-block-e {
width: 100%;
float: none;
}
}
DEMO
You can also look at this demo from the jQM site:
http://demos.jquerymobile.com/1.4.5/grids-custom-responsive/
I have this markup:
<div class="girls" style="text-align:center; margin-top:100px">
<img src="images/1.png" />
<img src="images/2.png" />
<img src="images/3.png" />
<img src="images/4.png" />
and this css (I'm using Twitter Bootstrap) :
img {
height: auto;
max-width: 100%;
vertical-align: middle;
border: 0;
-ms-interpolation-mode: bicubic;
}
The images have equal width and height and are displayed inline.
On my resolution are ok, fit the entire width (1366px), but on lower resolutions the images don't fit.
So, I need to keep the proportions on every screen resolution ( lower than 1366px in my case)
I've found this picturefill
Which I think is helpful for me, but I'm thinking that it's a simpler solution for my case because I have 4 images which I need to display them horizontally and make them scale on every resolution.
Thanks!
You can set the style width attribute of the images to 25%, without specifying height. That's gonna work if you're always putting 4 images, they have the same width between them and your container div is always at 100%.
HTH
Francisco
If you are using Twitter Bootstrap, then use markup properly like in Twitter Bootstrap documentation:
<div class="row-fluid">
<div class="span3">
<img src="http://placehold.it/350x400"/>
</div>
<div class="span3">
<img src="http://placehold.it/350x400"/>
</div>
<div class="span3">
<img src="http://placehold.it/350x400"/>
</div>
<div class="span3">
<img src="http://placehold.it/350x400"/>
</div>
<div>
http://jsfiddle.net/zNLBG/