I am trying to overlay an image over another base image.
The images that I am using do not conform to a particular size but varies from page to page.
Each image overlay uses a style sheet similar to the one mentioned below:
#image1 {
position: absolute;
top: 44.594%;
left: 30.642%;
transform: translate(-50%, -50%);
}
The base image uses a style sheet similar to the one mentioned below:
.base-image {
position: relative;
text-align: center;
}
Thus far, if the image is smaller than the screen size I don't have any issues.
If it is larger than the current screen size, the positions are relative to the screen size.
If I change the base-image position to absolute, I do get the effect I am interested in but the rest of my page becomes hidden under the base-image.
Is there anything in CSS that I can do to achieve my desired effect?
One of the fragments of a page:
<div class="base-image">
<img src="Content/Images/baseimage.jpg" />
<div id="image1">
<img src="Content/Images/image1.jpg" alt="image1" />
<br />
<span>Some Text</span>
</div>
<div id="image2">
<img src="Content/Images/image2.jpg" alt="image2" />
<br />
<span>Some Text 2</span>
</div>
...
</div>
The question is similar but does not address my problem directly:
Html Image over image
Their solution is what I have been using thus far for me to overlay the image. But for some reason, when the image resolution is larger than the screen size, the resultant overlay appears to be scaled down to fit the screen resolution. The image locations are therefore all wrong with respect to the base image.
I am pretty sure you can make a <div> with the same position properties as your current picture and then have the pictures inside the <div> have a position:fixed and then move the pictures as you like with top:10%; left:10% and etc
Hope this helps
Related
How can I resize two images via a percentage of themselves (their native size) and have those images appear horizontally adjacent without space between them?
The trouble I am having is the containing divs appear to be sized according to the contained images original dimensions, not the resized dimensions. Setting display:inline-block; does prevent them from wrapping, but only if the width of the view is wide enough to accommodate the original image sizes. It does not reduce the size of the div. I feel like I am overlooking something obvious, but am too close to see it.
This code is based on this answer to this question. I tried it with figure elements instead of divs per the same answer and with many variations with no luck.
Some of the other answers I was not able to use because my solution constrained to an antiquated wiki html editor that filters out attributes and tags it does not like on save (e.g. srcset).
.img-box {
width: fit-content;
display: inline-block;
}
.img-box img {
width: 25%;
}
<div>
<div class="img-box">
<img src="https://www.google.com/images/srpr/logo11w.png" />
</div>
<div class="img-box">
<img src="https://www.google.com/images/srpr/logo11w.png" />
</div>
</div>
I am redesigning a website for fun and I was messing around with some JQuery and some CSS effects. When you click on an arrow, everything on the page gets pushed down and a video comes up. The issues is I'm trying to create a section for an image. However, changing the background-size of the image to cover ends up making the entire image take up the screen. If I manually change the size of the image then the image is distorted.
Here is the HTML:
<section id="content">
<img src="http://res.cloudinary.com/dvrqqa6ja/image/upload/v1466799500/background_image_mjh10z.jpg"class="stuff"> </img>
<h1>Click the arrow to view Kai Greene's Scar Story</h1>
<span class="msg"><button = class="btn btn-danger">Sign up for our News Letter</button></span>
</section>
<article class="buy">
<h1 class="products text-center">View other products</h1>
</article>
</div>
Here is the CSS:
.stuff{
margin-top: 100px;
background-soze: cover;
position: absolute;
left: 0px;
top: 0px;
z-index: 0;
}
You can view the entire code on codepen: http://codepen.io/sibraza/pen/wWgqBO
Instead of background-size, use width or height to set your desired image size. You can also use object-fit: cover to keep the image aspect ratio no matter what size you set. Its like doing a "cropping" effect.
You would probably have to change the size of the image manually. Setting the width to a certain value and setting height to auto or visa versa should not distort the image. So setting either width or height to auto shouldn't distort the image.
http://www.w3schools.com/css/css_rwd_images.asp is a helpful resource for image sizing in CSS
I received HTML & CSS layout that should be working fine. However, I'm experiencing some strange problems for which I'm not sure why do they occur.
At the bottom of the following this website there is slider that should display couple of photos with text and by clicking on arrows it should slide them. The problem is I can't position neither arrows, nor wrapper containing images.
As you can see arrows(CSS classes: .strelica-lijevo and .strelica-desno are currently behind the image wrapper (CSS class: .slike-wrapper) when they should be left (.strelica-lijevo) or right (.strelica-desno).
Code can be seen directly on the website. Any help would be appreciated.
There are some issues with the HTML and CSS - you should either try to contact whoever delivered this slider to get support for implementing it or you could try by yourself as follows (just checked the markup and CSS and maybe this helps):
Your current HTML:
<div class="w-clearfix main-content karta">
<div class="slike-wrapper">
<a class="w-inline-block featured-male-slike karta" href="/zagreb/category/to-see/2/zagreb-is-the-capital-and-the-largest-city-of-croatia/5">
<img class="featured-male-slike" src='/Content/610ddd4a-b9a7-45f8-ac56-66eec5968329.jpg' />
<div class="potpis-mala-slika-featured">
<div class="potpis-ispod-slike">Zagreb is the capital and the largest city of Croatia</div>
</div>
</a>
<a class="w-inline-block featured-male-slike karta" href="/zagreb/category/to-see/2/museum-of-broken-relationships/8">
<img class="featured-male-slike" src='/Content/3a6ee262-676f-4599-9f97-6b9c48136449.jpg' />
<div class="potpis-mala-slika-featured">
<div class="potpis-ispod-slike">Museum of Broken Relationships</div>
</div>
</a>
</div>
<div class="strelica-lijevo"> <img src='/Content/strelica-lijevo.svg' /> </div>
<div class="strelica-desno"> <img src='/Content/strelica-desno.svg' /> </div>
</div>
could be changed into:
<div class="w-clearfix main-content karta">
<div class="strelica-lijevo"> <img src='/Content/strelica-lijevo.svg' /> </div>
<div class="slike-wrapper">
<a class="w-inline-block featured-male-slike karta" href="/zagreb/category/to-see/2/zagreb-is-the-capital-and-the-largest-city-of-croatia/5">
<img class="featured-male-slike" src='/Content/610ddd4a-b9a7-45f8-ac56-66eec5968329.jpg' />
<div class="potpis-mala-slika-featured">
<div class="potpis-ispod-slike">Zagreb is the capital and the largest city of Croatia</div>
</div>
</a>
<a class="w-inline-block featured-male-slike karta" href="/zagreb/category/to-see/2/museum-of-broken-relationships/8">
<img class="featured-male-slike" src='/Content/3a6ee262-676f-4599-9f97-6b9c48136449.jpg' />
<div class="potpis-mala-slika-featured">
<div class="potpis-ispod-slike">Museum of Broken Relationships</div>
</div>
</a>
</div>
<div class="strelica-desno"> <img src='/Content/strelica-desno.svg' /> </div>
</div>
This would just change the order of the elements - 1st the left arrow, than the gallery, than the right arrow - so they're displayed next to each other. Guess this could be changed in another way, but this is the easiest approach withouth having to change too much in the CSS.
In the CSS
.featured-male-slike.karta
{
clear: right;
display: inline;
float: left;
margin-top: 30px;
overflow: hidden;
/* position: absolute; */ /* <--comment position abolute out */
}
comment "position: absolute;" out - you could also remove it, but it's better to keep it just so you can check with whomever created this slider for you, maybe there's some other way to fix the slider as you mentioned it should be working as it is. Because of this position:absolute the gallery would still be displayed above the left arrow, removing it has the purpose to keep the CSS-property float:left for all three elements - left arrow, gallery, right arrow, so they will be displayed next to each other.
Next is up to you - the images are displayed not positioned correctly because they have a different height, and the css for the img is height: auto, meaning that the height for each img depends on the actual calculated height (as both images are scaled down from bigger original images). You could either try to display images with the same size, or you can add css to set a fixed height for both images, e.g.
.slike-wrapper img
{
height:140px;
}
as the left image has a calculated height of 158px and the right image has 140px. As I only tested this directly in the browser's web developer tools, I can't guarantee that this approach would work for you, but you can give it a try.
On this grammar page there's a main 590px X 183px image at the top and 5 121px X 137px images at the bottom, aligned horizontally next to each other:
The bottom images are a resized crop of the main image at the top. In the screenshot example, the 3rd image at the bottom is the resized crop of the image at the top, buses. If you click on the first bottom images (books) it will take you to a page where books is also the image at the top (like buses above).
All this long-but-hopefully-clear introduction, is to ask how can I horizontally-align the the bottom images as a resized crop of the images at the top?
Now the bottom images were cropped and resized offline, and then uploaded as new files. So to visit all the 5 pages linked to from the bottom images, one has to download 10 image files. But if I could resize and crop (and still have the images horizontally aligned), those would be just 5 files.
I tried margin-left (and height) to resize and crop:
<img style="height:135px; margin-left:-290px;" src="http://www.imparare-inglese.it/uploads/1/1/1/6/11169156/7674785.png"/>
<img style="height:135px; margin-left:-610px;" src="http://www.imparare-inglese.it/uploads/1/1/1/6/11169156/6647450.png"/>
But just as I set the margin-left on the 2nd img, the 2nd image goes over the first. How do I prevent that? What am I missing?
Example with tables: http://jsfiddle.net/EZnAg/
Place the image inside a div, apply a width, height, float:left, position:relative and overflow:hidden on that div containing the image, then absolute position the image as required. If the image needs a faux/css resize, apply that in css too.
* {
padding:0;
margin:0;
}
.panels {
float:left;
}
.placeholder {
width:200px;
height:200px;
float:left;
overflow:hidden;
margin:0 20px 0 0;
}
.placeholder img {
/*width:100%;*/
}
<div class="panels">
<div class="placeholder">
<img src="http://www.jakss.co.uk/common/images/shell/header/client-logo.png" />
</div>
<div class="placeholder">
<img src="http://www.jakss.co.uk/common/images/shell/header/client-logo.png" />
</div>
<div class="placeholder">
<img src="http://www.jakss.co.uk/common/images/shell/header/client-logo.png" />
</div>
</div>
http://jsfiddle.net/seemly/PmUzY/
If you reinstate the width:100%; on the .placeholder img in my jsfiddle, hopefully this provides the effect you want, or at least gives you a head start?
cropped images are actualy new created images (from the original ones)with different aspect ratio. assuming that these images are totally different images(and not the same images just shown as width="smallpx" height=smallpx"), u can place them inside a div something like this
<div id="all_image contained" style="width: 300px;">
<div style="width: 100px; float:left">
<img src="images/img1.jpg" width="80px" height="50px"/>
</div>
<div style="width: 100px; float:left">
<img src="images/img2.jpg" width="80px" height="50px"/>
</div>
<div style="width: 100px; float:left">
<img src="images/img3.jpg" width="80px" height="50px"/>
</div>
</div>
in order to cropping, u have to use jquery script, to create new images with small aspect ratio and dimensions....
or else if u want to display the same large images, in small thumbnail size, then u may use a fixed size div and set overflow as hidden
I'm taking a crack at writing a Javascript-based image gallery. Right now I have the code set so that I know the images will all be at the same height, but...
How can I arrange my markup and CSS so that all of the images will display on just one line, and when a new one would be outside the width of the browser window, the parts of the image that are 'out of bounds' are simply hidden and don't display on the next line?
I've been experimenting with overflow, float, and display in various ways for the images themselves and their container div to no avail. There must be something simple I'm overlooking here.
Right now the markup looks like:
<div id="slider">
<img src="img1.png" />
<img src="img2.png" />
<img src="img3.png" />
</div>
How should I style this so it displays on one line, even if the combined width of the images is greater than the width of the browser window?
Thanks.
#slider {
white-space: nowrap;
overflow : hidden;
width : 100%
}