I am trying to create a virtual gallery that dynamically generates an image (or set of images) based on what artwork is being shown and how large it is. I am having trouble keeping the image positions absolute when scaling the image size in my browser. That is, the images will scale unevenly when the browser display height changes. See the CodePen below for what I mean.
Does anyone have suggestions as to how to fix this? I noticed that Fine Art Multiple (click the link, then the View in Room button) seems to auto-generate their image using either a custom function or a 3rd party program. Does anyone know how I could viably do this, if what I want isn't possible in CSS?
Fine Art Multiple`s virtual gallery:
https://fineartmultiple.com/buy-art/alex-katz-reclining-figure/
FAM's example gallery works because it's not as responsive as yours. As you noted, it's a generated image that is positioned in the center.
Instead of using percentages I set some fixed widths for you and also moved the room image into a background property instead of having it as an additional img element.
I also made sure the person's silhouette disappears on small screens by shifting to the left and off-screen just like in the example.
Most of this positioning is reliant on a left margin combined with transform:
margin-left: 50%;
transform: translate(-50%,0);
This technique can be used to perfectly center and offset any element.
http://codepen.io/anon/pen/RKpver?editors=0100
Related
I am attempting to create a custom world map using an image where you can click on a button that is over a "continent". This is an ionic app and is expected to be launched on both mobile and desktop. The only real answer i can find to fixing this problem is using CSS with position: absolute; and then setting the pixels (ex: top: 50px; left: 30px;). I am worried that the buttons will not stay in the correct position when it is viewed on different web browsers and when used via a mobile device. Is there a way that i can make sure that the buttons stay in the desired position no matter what, or is the only way to do it is through CSS positioning and px manipulation? attached is the photo of the world map (some parts cut out: https://imgur.com/a/yzPRVh1 ) i am trying to implement this on. I want to have a clickable element on top of each continent and centered. Thank you!
You can place a div over the picture and use percentages over pixels but it will still need to be adjusted with #media-queries.
I’m currently trying to wrap my head around solving this layout with Ionic and CSS:
This is the result I achieve even after spending quite some time with it:
I've recreated the basic setup on the home page: here
The layout consists of a navbar, a fullscreen image and text-content below that. The gradient is constructed using a ::after attribute in CSS as I don't want to hard embedd the gradient in the image file with Photoshop and the likes. I had to construct the fullscreen image using a ‚position:absolute‘ attribute:
.happening-image {
top: 0;
right: 0;
bottom: 0;
left: 0;
position:absolute; }
because for reasons beyond my knowledge, not using ‚position:absolute’ results in the image not being displayed in fullscreen but being 2 or 3 pixels smaller than the total width and thus leaving a slim border of background color around the image:
Once I do use the ‚position:absolute’ attribute however my layout becomes a complete mess because the text content is being placed all over the image content.
This is where I'm struggling to come up with a solution that tidly places the text content below the fullscreen image. Using padding is, to my understanding, not possible as quick fix as I need the layout to be independent from the image content:
if I use padding based on the height of portrait sized images, the content gets too much offset when for landscape sized images and vice versa. I could try to target landscape and portrait images using different .css classes for each and setting and matching padding, I do however feel that using padding is not the best solution.
Can someone point me to my error or a robust, content-independent solution here that keeps Image and text content tidly in order while maintaining the layout?
According to your example, the border around the image is happening because of the padding attribute in the ion-content tag, here:
If you remove that padding the image will have no space around.
By the way, the position:absolute; did the trick, because it makes the image get out of the page flow, and so, it acted as a child of the body, which doesn't have any padding/margin around.
Edited
Also, you need to remove the position:absolute from your image and add padding:0; to the tag above it, as it is adding a little space around from padding.
And from what I understood, the image and text will behave as you wished.
Situation:
I created a full screen layover navigation for a html5 webpage including links displayed as images. I used images because of the special hover effect, which is not possible in code.
This means that my links such as Home, About, Portfolio, Contact are made out of images (and not text) and displayed in a list.
I created two images per link: 1 for normal state and 1 for hover state.
I used the replacing img technique shown here:
.foo img:last-child{display:none}
.foo:hover img:first-child{display:none}
.foo:hover img:last-child{display:inline-block}
Issue: The navigation works well on a large screen, but the trouble starts when scaling-down the viewport. The images controlled by max-width behave separate from each other and do not scale at a similar rate when scaling down the screen. Of course this relates to the biggest image (which hits the viewport border) to scale first and the smaller later. In my case: the Portfolio image will scale earlier than the Home image. This results in a strange looking navigation, as the images differ in size at some point.
Some other elements I considered:
I can make smaller images for smaller screens, but that would make a lot of images too load.
I can make all images the same size as the biggest image. But it means the smaller word will have empty spaces on the left and right of the word. This empty space will also activate the hover state, which makes it look strange (hover state activates while I'm not on the link itself (visually, not technically).
Question:
How can I use an image-based navigation and scale down the navigation links/images equally when scaling down the viewport?
I made a JSFiddle for testing: DEMO
Thanks in advance.
I've been looking at this for a while and I'm beginning to think this isn't possible. The root of the problem is that each image would need to be aware of the largest image, or at least each of the <li>s would need to be aware of the other ones' dynamic height, which isn't possible with some sort of DOM manipulation. Even with flexbox I'm unable to make this work.
My advice would be to create each image the same width, using PNG transparency, then simply use an image map to activate the hover state over only the button area of each image. It's a bit of work but I can't think of a better way. See this StackOverflow question for ways to make the image maps.
I created this image gallery that an image is revealed on hovering but the revealed image is in a different place in every computer/browser i open it in but for the life of me I can't figure out why.
I just want the revealed image to appear in the middle without being on top of other images but when i get it to that setting on one computer it looks different on another.
I'm new to coding so I really hope someone helps. Here's the link to my codepen: image gallery
[1]: http://codepen.io/zenturtle/pen/ezDGC
For consistent placement, you need to give the #perimeter div position: relative, so that the positioning of the large images will always be in relation to the containing div, which has a fixed width. Otherwise, the positioning is in relation to the browser/viewport, meaning that it will be different depending on the size/width of the browser.
#perimeter {position: relative;}
You will probably have to adjust all of the large image coordinates now. There are more efficient ways to do this, though. You should be able to place all of those images with one CSS rule, rather than separate ones for each image.
http://jsfiddle.net/LFtHg/
I'm trying to create my first responsive website. For this, I'm including an image. This image has a caption which should be displayed in a transparent overlay. However because opacity settings are passed to child elements, I have removed the text from the container.
I cant get the overlay to display, at all (because it has no content inside it). I cant really add a fixed height as I want to image to respond to changes in browser size. How can I ensure this is displayed?
Thank you,
J
Edit, also what would the best way to scale the overlay as the browser resizes. I'm unsure if this approach is even possible.
First of all, you can use an RGBA background ( background: rgba(0,0,0,.5); ) instead of using opacity.
Secondly, you need explicitly set a width for your span.figcaption (you can also do that by specifying both left and right offset properties)
Perhaps this demo http://dabblet.com/gist/2778608 might also help you (image can be of any size - resize the browser window to see how everything resizes).
Adding the following rules to your existing sample effectively stretches the .figcaption elements to fully cover the .figure, fiddle:
.figure {position:relative;}
/*these could be different so that the overlay appears larger than the caption*/
span.figcaption {position:absolute;top:0;right:0;bottom:0;left:0;}
p.figcaption {position:absolute;top:0;right:0;bottom:0;left:0;}
You can arbitrarily adjust the values to a % setting so that the caption appears centered etc.
BTW, you know that your implementation is not yet liquid, right?