HTML: Stop pictures from overlap on mobile view (responsive design) - html

I've got a website, based on wordpress and the responsive design "Mystile".
I use the following html code to display three pictures side by side:
<div style="position: absolute;"><img src="myimgsrc" alt="" /></div>
<div style="position: absolute; margin-left: 250px;"><img src="myimgsrc" alt="" /></div>
<div style="position: absolute; margin-left: 500px;"><img src="myimgsrc" alt="" /></div>
This works flawlessly on the computer.
As you can see on the picture.
But on a mobile device it looks terrible.
Like this:
What can should I do?
Thank you very much.

The easiest is just to display the images inline. They will then wrap under each other if there isn't enough space to fit beside one another:
html, body {margin:0;}
.hmm a {display:inline-block; margin:10px 0 0 10px;}
.hmm a img {display:block; margin:0;}
<div class="hmm"><img src="http://www.placehold.it/240x50" alt="placeholder" /><img src="http://www.placehold.it/240x50" alt="placeholder" /><img src="http://www.placehold.it/240x50" alt="placeholder" /></div>
If you want to get a little more advanced you can use media-queries to change the style for different sized viewports:
html, body {margin:0;}
.hmm a {display:inline-block; margin:10px 0 0 10px;}
.hmm a img {display:block; margin:0;}
#media all and (max-width: 750px) {
.hmm a:first-of-type img {width:490px;}
}
#media all and (max-width: 510px) {
.hmm a {
display: block;
margin:10px;
}
.hmm a img {
width:100%!important;
}
}
<div class="hmm"><img src="http://www.placehold.it/240x50" alt="placeholder" /><img src="http://www.placehold.it/240x50" alt="placeholder" /><img src="http://www.placehold.it/240x50" alt="placeholder" /></div>
^ Go 'full-page' and resize to see this one working.

Related

Logo not responsive Bootstrap 3

Something is preventing my logo from being responsive. I have all the correct tags I think...
<div id="row" class="image-responsive">
<img src="images/logo.png" alt="Top Jocks" border="0">
</div>
In overstyle.css:
#logo {
max-width:100%;
}
#logo img {
display: block;
margin: 0 auto;
padding: 0px;
}
Page with the problem.
Thanks in advance.
Dave
As mentioned in the comments, the .img-responsive class should be applied to the image itself.
Images in Bootstrap 3 can be made responsive-friendly via the addition of the .img-responsive class. This applies max-width: 100%;, height: auto; and display: block; to the image so that it scales nicely to the parent element.
The bootstrap.css already contains the instruction img { border: 0; }.
So try to use
<img class="img-responsive" src="images/logo.png" alt="Top Jocks">
instead of
<div id="row" class="image-responsive">
<img src="images/logo.png" alt="Top Jocks" border="0">
</div>
If my solution works as it should, you can remove this code from overstyle.css:
#logo {
max-width:100%;
}
#logo img {
display: block;
margin: 0 auto;
padding: 0px;
}
If you use Bootstrap then use class
img-responsive
Or else give css property to your logo image or class,
img {
width:100%;
max-width:100%;
}
You need to add class img-responsive in img tag.
<img src="images/logo.png" class="img-responsive" alt="Top Jocks" border="0">

Div Images Side by Side

Good morning, I am trying to put 2 images, side by side within a div.
I have tried float left and float right, but to no success.
It works on a separate HTML page, but not when I add it to my current page.
very strange, but a simple resolution, but cannot see it...
Thanks
#mikeimgs {
width:70%;
margin-top: 10px;
margin-right: auto;
margin-left: auto;
}
.img1 {
margin-top:10px;
float:left;
}
.img2 {
margin-top:10px;
float:right;
}
<div id="mikeimgs" class="fluid">
<div class="fluid img1"><img src="file:///G-DRIVE mobile USB/STR Website/STRv1/August 2016/Mike-Vittiimg.jpg" alt="" width="200" height="200"/></div><div class="fluid img2"><img src="file:///G-DRIVE mobile USB/STR Website/STRv1/August 2016/Odyssey250.jpg" alt="" width="200" height="200"/></div>
</div>
` with the page i'm trying to create.
The div containing the image should not have fluid class, additionally you do not need float left and float right, they both will be float left.
#mikeimgs {
width:70%;
margin-top: 10px;
}
.img {
margin-top:10px;
float:left;
width:200px;
}
<div id="mikeimgs" class="fluid">
<div class="img"><img src="file:///G-DRIVE mobile USB/STR Website/STRv1/August 2016/Mike-Vittiimg.jpg" alt="" width="200" height="200"/></div><div class="img"><img src="file:///G-DRIVE mobile USB/STR Website/STRv1/August 2016/Odyssey250.jpg" alt="" width="200" height="200"/></div>
</div>
Your code as it stands seems to run fine here. However there's no CSS provided for the .fluid class. Is it possible that this class is overriding your expected outcome?

Bigcartel mobile only

I'm trying to get my bigcartel page to show
<div style="margin-top: 0px; img align: middle">
<img width="420" height="42" style="vertical-align:middle;" src="https://i.imgsafe.org/52c5068376.png" alt="PAF ENTRY">
</div>
on mobile devices only while trying to show an exact copy of the code for browsers only
here is the page
http://pafclub.bigcartel.com/entry
And this is what I have so far:
<div class="mobileHide">
<div style="margin-top: 0px; img align: middle">
<img width="420" height="42" style="vertical- align:middle;" src="https://i.imgsafe.org/52c5068376.png" alt="PAF ENTRY"> </div>
<style type="text/css">
.mobileHide { display: inline;}
/* Smartphone Portrait and Landscape */
#media only screen
and (min-device-width : 320px)
and (max-device-width : 480px){ .mobileHide { display: none;}}
</style>
<div class="mobileShow">
<div style="margin-top: 120px; margin-bottom: 10px; text-align: center;">
<img width="420" height="42" style="vertical-align:middle;" src="https://i.imgsafe.org/52c5068376.png" alt="PAF ENTRY">
</div>
<style type="text/css">
.mobileShow { display: none;}
/* Smartphone Portrait and Landscape */
#media only screen
and (min-device-width : 320px)
and (max-device-width : 480px){ .mobileShow { display: inline;}}
</style>
it shows one version of the image but when I check on a mobile device there is no image at all.
The theme has code that adds a margin to custom page bodies that you'll need to override. Add this to the bottom of Customize Design > Advanced > CSS to remove it:
#entry .page {
margin: 0 auto;
}
Then for your entry page, all you'll need is the following code to have the image display centered properly (on desktop and mobile)
<a href="/products">
<img style="width:100%;margin:0 auto;max-width: 427px;display:block" src="https://i.imgsafe.org/7da3920e19.png" alt="ENTRY">
</a>
i have worked on your problem, and got solution for this. Please check the code.
.mobileHide { display:table; height:100%; text-align:center; vertical-align:center; width:100%;}
.middle{ display:table-cell; height:100%; vertical-align:middle; width:100%;}
.middle a{ max-width:80%; display:inline-block;}
.middle a img{ max-width:100%;}
html, body {
height: 100%;
margin: 0px;
}
<div class="mobileHide">
<div class="middle">
<a href="/products">
<img width="420" height="" src="https://i.imgsafe.org/52c5068376.png" alt="PAF ENTRY">
</a>
</div>
<div style="clear:both;"></div>
</div>

Three images side by side, responsive without scaling

I cannot find the exact answer to my question, so hopefully someone can help me.
I have three images. I want them side by side on a large screen.
On a smaller screen (tablet) I want two of them to be in rows.
And on small phone screen I want them all to be in rows above each other, centered.
The code that I have so far is:
<div align="center">
<div style="width: 371px; float: left;"><img src="{{media url="wysiwyg/magenthemes2/images/review1.png"}}" alt="" width="371" height="270" /></div>
<div style="width: 371px; float: left;"><img src="{{media url="wysiwyg/magenthemes2/images/review2.png"}}" alt="" width="371" height="139" /></div>
<div style="width: 371px; float: left;"><img src="{{media url="wysiwyg/magenthemes2/images/review3.png"}}" alt="" width="371" height="139" /></div>
</div>
But this doesn't work right. It is also not centered. I'd like it to render like this:
Responsive example on different screen sizes
The best way to do this is to give the parent <div> a class name, and then apply different styles to it in different #media queries. More can be read about #media at MDN. you could use this site, or this site for a simpler but less complete overview, as a cheatsheet for which media queries you could use.
An example of some code that would work for a selection of devices is:
#media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
.imagebox > img {
float:left;
}
}
#media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {
.imagebox > img:first-child {
float:left;
}
}
<div align="center" class="imagebox">
<div style="width: 371px; float: left;"><img src="https://placekitten.com/250/300" alt="" width="371" height="270" /></div>
<div style="width: 371px; float: left;"><img src="https://placekitten.com/250/150" alt="" width="371" height="139" /></div>
<div style="width: 371px; float: left;"><img src="https://placekitten.com/250/150" alt="" width="371" height="139" /></div>
</div>
Instead of float you can also work with the text-align attribute. In the following example you can see how I used it for boxes on a front-page. They automatically adjust to different screen-sizes (click on "Run code snippet" and then on "Full page").
.entries-box {
/* Style for box containing Frontpage boxes */
text-align: center;
padding: 0;
}
.entry {
/* Style for a Frontpage box */
display: inline-block;
text-align: left;
padding: 0.4em 0.8em 0.4em 0.8em;
border: 1px solid black;
margin: 0 1em 0.4em 0;
border-radius: 10px;
background: #007f59;
}
<div class="entries-box">
<div class="entry newest-e">
<b>Title of Storie</b> - Genre (Lang icon)
<br>'Excerpt of newest entry, max. 2 lines
<br>Second line of excerpt...'
<br>_User_
</div>
<div class="entry newest-e">
<b>Title of Storie</b> - Genre (Lang icon)
<br>'Excerpt of newest entry, max. 2 lines
<br>Second line of excerpt...'
<br>_User_
</div>
<div class="entry newest-e">
<b>Title of Storie</b> - Genre (Lang icon)
<br>'Excerpt of newest entry, max. 2 lines
<br>Second line of excerpt...'
<br>_User_
</div>
</div>

How do I get these social icons to be straight centered on the page on all browsers?

Link to website: foxweb.marist.edu/users/kf79g/contact.php
This is it. The last step I have to fix before deploying my website and finally finishing it. But I do not know how to resolve this issue. On medium and small screens, I am having a lot of trouble with my social icons. I want the whole thing on medium and small devices to be centered and 100% responsive. I have tried making a container to make them responsive, but no matter what I do, it always looks messy in IE 7-10. The icons are moving to the next line instead of staying on one line evenly as the page width gets smaller and smaller. I tried adjusting the margins, but that didn't helps since that ruined my center attribute for the whole page. I simply do not know what to do or how to fix this issue. If anybody can help me I would really appreciate it.
Visual representation of problem (IE):
http://tinypic.com/r/nla7eq/5
What I want it to look like (modern browsers):
http://tinypic.com/view.php?pic=vp9gg7&s=5
HTML:
<h2> Social networks </h2><br/>
<div id = "center_icons">
<img src="images/facebook.png" alt="facebook" style="margin:1px;">
<img src="images/google-plus.png" alt="google plus" style="margin:1px;">
<img src="images/linkedin.png" alt="linkedin" style="margin:1px;">
<img src="images/github.png" alt="github" style="margin:1px;">
</div>
<br/>
</div>
</section>
Main CSS:
#details_section {
max-width:100%;
float:left;
margin-right:20px;
}
Large screens:
#details_section {
width:320px;
}
Medium screens:
#center{
width: 450px;
display: block;
margin-left: auto;
margin-right: auto;
}
#center_icons{
width: 213px; /*this value is changing for IE and chrome*/
display: block;
margin-left: auto;
margin-right: auto;
}
Small screens:
#center{
width: 220px;
display: block;
margin-left: auto;
margin-right: auto;
max-width:100%;
}
#center_icons{
width: 214px; /*this value is changing for IE and chrome*/
display: block;
margin-left: auto;
margin-right: auto;
max-width:100%;
}
You could also remove spaces between "=", and use " instead of '.
<div id = "center">
<div id='details_section'>
should be
<div id="center">
<div id="details_section">
You should also indicate the image size somewhere.
<div id="container">
<div id="center_icons">
<img src="images/facebook.png" alt="facebook" width="40" height="40">
<img src="images/google-plus.png" alt="google plus" width="40" height="40">
<img src="images/linkedin.png" alt="linkedin" width="40" height="40">
<img src="images/github.png" alt="github" width="40" height="40">
</div>
</div>
And a simpler CSS would be:
div {border: 1px red solid;padding: 5px} /*this is only for us to see it when testing*/
#container {
text-align:center;
}
#center_icons{
width: 214px; /*this value is changing for IE and chrome*/
display: block;
margin-left: auto;
margin-right: auto;
max-width:100%;
}
Check it working here: http://codepen.io/anon/pen/mAjzo
Just use <center> </center> in code instead of Div id "center".
you need to change your CSS properties just measure your screen co-ordinates and put it in margin or you can use HTML5 to solve this problem.