image size using different media queries - html

I have the following problem. I have a block split in two div's left and right, the left contain image with 640x461 and the right one split also in two div's
one contains text and beneath it an image 640x342. on the mobile site these are underneath each other image(640x461),text block then image(640x342), but given different screen size using media e.g #media (min-device-width: 568px) the right div(text+img) should float next to left div, but the problem is that the height of my left image still smaller than the height of right div. What should i do here?
HTML:
<div class="block_acc">
<div class="lp-bild-left">
<a>
<img src="640x461.jpg" />
</a>
</div>
<div class="lp_column">
<div class="lp_description">
<div class="lp_textbox_wrapper">
<span class="headline">text</span>
</div>
</div>
<div class="lp-bild-right">
<img src="640x342.jpg" />
</div>
</div>
</div>
CSS:
#media (min-device-width: 568px) {
.lp-bild-left{
float: left;
width: 50%;
}
.lp_column {
float: left;
width: 50%;
}
}

OK, check this code:
<div class="block_acc">
<div class="lp-bild-left">
<a href="#">
<img src="http://planeon.net/wp-content/uploads/hot-air-balloon.jpg" />
</a>
</div>
<div class="lp_column">
<div class="lp_description">
<div class="lp_textbox_wrapper">
<span class="headline">text</span>
</div>
</div>
<div class="lp-bild-right">
<img src="http://www.whudat.de/images/Albuquerque-Balloon-Fiesta_4.jpg" />
</div>
</div>
</div>
CSS...
.block_acc {
display: block;
overflow: hidden;
}
#media (min-device-width: 568px) {
.lp-bild-left {
float: left;
width: 50%;
}
.lp-bild-left img {
height: auto;
width: 100%;
}
.lp_column {
float: left;
width: 50%;
}
.lp_column .lp-bild-right {
max-width: 100%;
}
.lp_column .lp_textbox_wrapper {
line-height: 0;
}
.lp_column .lp_textbox_wrapper .headline {
font-size: 1vw;
line-height: normal;
}
.lp_column .lp-bild-right img {
width: 130%;
}
}
https://fiddle.jshell.net/jonathanzuniga/at57emmd/

Related

How do I create a responsive two column layout using divs instead of tables?

How do I create a responsive two column layout using divs instead of tables?
The left div will have text and a call to action. The right div will have an image or is it better to have a transparent background and a png image?
I want both divs to be aligned and responsive. The divs should also stack on top of each other at different screen resolutions.
Below is what I've done so far. It's not perfect. Is there a way of cleaning this up so that I don't run into issues across multiple browsers.
Thank you.
<style type="text/css">*{
box-sizing: border-box;
padding: 10px;
}
.column {
float: left;
width: 300px;
}
.center {
padding: 50px 0;
}
.row:after {
content: "";
display: table;
clear: both;
}
#media screen and (max-width: 900px) {
.column {
width: 50%;
}
}
#media screen and (max-width: 600px) {
.column {
width: 100%;
}
</style>
<div class="row">
<div class="column" style="background-color:#e0e620;">
<div class="center">
<p style="font-size:18px; ">The Information is now available as an audiobook.<br />
<a class="link-button-green" href="" title="Info guide">Listen now</a></p>
</div>
</div>
<div class="column" style="background-color:#E5E5E5;">
<img src="https://www.w3schools.com/css/img_forest.jpg">
</div>
You can use flex instead of float to put the columns next to each other. In your #media query, you can remove flex for smaller screens so that the columns are displayed under each other.
The image width should be 100% of the flex column. The CSS doesn't have to be inline.
HTML
<div class="row">
<div class="column left">
<div>The Information is now available as an audiobook.<br />
<a class="link-button-green" href="" title="Info guide">Listen now</a>
</div>
</div>
<div class="column right" >
<img src="https://www.w3schools.com/css/img_forest.jpg">
</div>
</div>
CSS
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
}
.row {
display: flex;
}
.column {
flex:1;
}
.left {
background-color:#e0e620;
padding:20px;
}
.right {
background-color:#E5E5E5;
}
img {
width:100%;
}
#media screen and (max-width: 400px) {
.row {
width: 100vw;
display:block;
}
}
See this jsfiddle: https://jsfiddle.net/tLubao5d/1/

Responsive Image Container

I'm trying to get a set of 8 images (all with same dimensions), to display in-line with equal spacing and respond to browser width.
Starting with 4 images over 2 rows then as the browser width decreases, for them to shrink to a certain point that they are still clearly legible, then move to 2 images over 4 rows. I've noticed that it does this without any styling but it also has a stage in between where it pushes one image down onto a new row, so 3-1-3-1. I want to avoid this.
Here's what I'm currently working with.
.features {
width: 100%;
display: block;
text-align: center;
}
.features img {
width: 220px;
margin: 10px;
}
<div class="features">
<img src="https://cdn.shopify.com/s/files/1/1899/1203/files/jupa-icon-lighweight-black.png?9028853389915552257">
<img src="https://cdn.shopify.com/s/files/1/1899/1203/files/jupa-icon-pocket-black.png?9028853389915552257">
<img src="https://cdn.shopify.com/s/files/1/1899/1203/files/jupa-icon-solar-black.png?9028853389915552257">
<img src="https://cdn.shopify.com/s/files/1/1899/1203/files/jupa-icon-battery-black.png?9028853389915552257">
<img src="https://cdn.shopify.com/s/files/1/1899/1203/files/jupa-icon-apple-black.png?9028853389915552257">
<img src="https://cdn.shopify.com/s/files/1/1899/1203/files/jupa-icon-compatible-black.png?9028853389915552257">
<img src="https://cdn.shopify.com/s/files/1/1899/1203/files/jupa-icon-connector-black.png?9028853389915552257">
<img src="https://cdn.shopify.com/s/files/1/1899/1203/files/jupa-icon-led-black.png?9028853389915552257">
</div>
Hope that makes sense. I'd like to do this just using CSS and HTML assuming that's possible.
A grid system using media queries to set the breakpoints for where you want the columns to change width is what you want. https://codepen.io/anon/pen/EmXrMm
CSS tricks has a good article on rolling your own grids here https://css-tricks.com/dont-overthink-it-grids/.
Or you could do the same using flexbox depending on the support constraints.
Note: border box stops the padding declaration adding additional width to the columns. cf is a clearfix, makes the container grow in size relative to the floated elements inside. Rest is pretty straight forward.
* {
box-sizing: border-box;
}
.cf:after {
content: " ";
display: table;
}
.cf:after {
clear: both;
}
.cf {
*zoom: 1;
}
.features__col {
width: 100%;
float: left;
padding: 15px;
}
.features__col img {
width: 100%;
}
#media (min-width: 400px) {
.features__col {
width: 50%;
}
}
#media (min-width: 800px) {
.features__col {
width: 25%;
}
}
<div class="features cf">
<div class="features__col">
<img src="https://placeholdit.imgix.net/~text?txtsize=47&txt=500%C3%97500&w=500&h=500" alt="" />
</div>
<div class="features__col">
<img src="https://placeholdit.imgix.net/~text?txtsize=47&txt=500%C3%97500&w=500&h=500" alt="" />
</div>
<div class="features__col">
<img src="https://placeholdit.imgix.net/~text?txtsize=47&txt=500%C3%97500&w=500&h=500" alt="" />
</div>
<div class="features__col">
<img src="https://placeholdit.imgix.net/~text?txtsize=47&txt=500%C3%97500&w=500&h=500" alt="" />
</div>
</div>
</div>
if you want the images to shrink you'll need to set some breakpoints with media queries and try using flexbox
.features{
display: flex;
flex-flow: row wrap;
justify-content: space-between;
}
.features img {
padding: 10px;
width: 310px;
height: 381px;
}
#media all and (max-width: 600px) {
.features img {
width: 50%;
height: 50%;
}
Try This :
.col {
width: 25%;
float: left;
text-align: center;
box-sizing: border-box;
}
#media screen and (max-width: 1285px) {
.col {
width: 50%;
float: left;
}
}
#media screen and (max-width: 670px) {
.col {
width: auto;
float: none;
}
img {
min-width: 220px;
}
}
#media screen and (max-width: 365px) {
img {
width:100%;
}
}
<div class="features">
<div class="col">
<img src="https://cdn.shopify.com/s/files/1/1899/1203/files/jupa-icon-lighweight-black.png?9028853389915552257">
</div>
<div class="col">
<img src="https://cdn.shopify.com/s/files/1/1899/1203/files/jupa-icon-pocket-black.png?9028853389915552257">
</div>
<div class="col">
<img src="https://cdn.shopify.com/s/files/1/1899/1203/files/jupa-icon-solar-black.png?9028853389915552257">
</div>
<div class="col">
<img src="https://cdn.shopify.com/s/files/1/1899/1203/files/jupa-icon-battery-black.png?9028853389915552257">
</div>
<div class="col">
<img src="https://cdn.shopify.com/s/files/1/1899/1203/files/jupa-icon-apple-black.png?9028853389915552257">
</div>
<div class="col">
<img src="https://cdn.shopify.com/s/files/1/1899/1203/files/jupa-icon-compatible-black.png?9028853389915552257">
</div>
<div class="col">
<img src="https://cdn.shopify.com/s/files/1/1899/1203/files/jupa-icon-connector-black.png?9028853389915552257">
</div>
<div class="col">
<img src="https://cdn.shopify.com/s/files/1/1899/1203/files/jupa-icon-led-
black.png?9028853389915552257">
</div>
</div>

How to implement an white box over an image correct in asp.net

I'm trying to make an booking box with an white background over an image on my front page. So far I have managed to put an box on top with the following code:
Code:
<div class="row">
<div class="col-sm-12 contentpage">
<div class="frontimage">
<img src="~/images/index.jpg" />
<div class="col-sm-4">
<div class="bookingbox">
</div>
</div>
</div>
</div>
</div>
Css:
.bookingbox {
background-color: white;
position: absolute;
height: 100px;
margin-top: -580px;
margin-left: 10px;
}
#media (min-width: 1200px) {
.bookingbox {
display: none;
}
}
The problem now is that when you going from, lets say 1600px to 1200px the white box moves, can't make it to be static inside the image.
All my images are set with the following css the they become responsive:
img {
max-width: 100%;
}
What should I change? any ideer?
Update:
The box fitting perfectly now.. but now the image is off the aligniment with the rest of the page.
Left side is good, but right side has become bigger somehow?
The answer here, you should use z-index to do this.
.bookingbox {
background-color: red;
position: absolute;
height: 100px;
width: 100px;
z-index: 2;
position: absolute;
top: 0;
}
.frontimage {
z-index: 1;
position: absolute;
}
#media (min-width: 1200px) {
.bookingbox {
display: none;
}
}
<div class="row">
<div class="col-sm-12 contentpage">
<div class="frontimage">
<img src="https://www.wonderplugin.com/wp-content/plugins/wonderplugin-lightbox/images/demo-image0.jpg" />
<div class="col-sm-4">
<div class="bookingbox">
</div>
</div>
</div>
</div>
</div>

Make images stack for mobile

I am trying to create a page with two images side by side on desktop, then have those images stack for mobile. I am making my browser window smaller to simulate a smaller screen. The images are not stacking on mobile. Here's my html:
<div class="container-lp">
<div class="col-2-lp">
<h4>Interior Decorating</h4>
<div class="overlay">
<img src="http://pjstagingdecorating.com/wp-content/uploads/2015/07/Interior-Decorating-Level-1B.jpg" alt="" />
</div>
<div class="overlay"></div>
</div>
<div class="col-2-lp last-lp">
<h4 class="landing-page">Home Staging</h4>
<div class="overlay">
<img src="http://pjstagingdecorating.com/wp-content/uploads/2015/07/Home-Staging-Level-1B.jpg" alt="" />
</div>
</div>
</div>
Here is my CSS for desktop:
.container-lp {
width: 100%;
max-width: 1280px;
min-width: 320px;
margin: 0 auto;
clear: both;
}
.col-2-lp {
float: left;
width: 45%;
margin-right: 5%;
}
.last-lp {
margin-right: 0;
}
.col-2-lp img {
width: 100%;
}
And my media query:
#media only screen and (min-device-width: 320px) and (max-device-width: 600px) {
.col-2-lp {
width: 100%;
float: none;
margin: auto;
}
.last-lp {
margin-right: auto;
}
}
There is no problem in your code. You cannot test device media queries on pc browser try this instead
#media only screen and (min-width : 320px) and (max-width : 600px) {
}
if this functionality is all you need, I would suggest looking up bootstrap. You can achieve the same thing without touching the CSS like this:
<div class="container">
<div class="row">
<div class="col-sm-6"><img src="#"></div>
<div class="col-sm-6"><img src="#"></div>
</div>
</div>
Here's an example:
Set everything to be 100%, then above a certain width set it 50%, then it should go side by side.
.image {
width: 100%;
}
#media screen and (min-width: 780px) {
.image {
width: 50%;
}
}
Here's a jsfiddle that shows a simple example

Float right div over left div

As you can see bottom I've two div inline/columbs (one-half - left of page, one half last - right of page). My goal is to float the 2° div (one half last) over the first when the page is resized.
Basically I want that the 1° div collapse under the 2°. Is there a way to do this?
The trouble is that I can only obtain the float left of 2° div under the 1°.
Advices?
<div>
<div class="one-half">
<h2>Title</h2>
<p style="text-align: justify;">Text</p>
<p style="text-align: justify;">Text.</p>
<p style="text-align: justify;">Text.</p>
</div>
<div class="one-half last">
<img src="#" class="shadow" alt="#" style="max-width: 455px;width: 100%;">
</div>
<div class="clearfix"></div>
</div>
.one-half {
width: 460px;
}
.last {
float: left;
}
Pure css and html way : for page resize detection, use media queries
#media screen and (max-device-width: 600px) {
.one-half {
display: none;
}
.last {
float: left;
}
}
EDIT
considering the comment, update css to
#media screen and (max-device-width: 600px) {
.one-half {
float:left;
}
.last {
float: left;
clear: left;
}
}