Lines behind image (top and bottom) - html

I have a centered image on my website, where i need a top and bottom line.
The catch here, is that i need both lines 1px in behind the image, so that they are "align" in top and bottom of the image. I tried using box-shadow but it doesn't work in IE8 (i know it's terrible).
Anyone who has a answer and dying to tell me?
A quick UPDATE to show you my issue:
I'm using bootstrap 2 and displaying a carousel for images. And when there are only one image, the line should be visible. It need to be able to run in IE8 for the customer.
Image example:
http://postimg.org/image/xi3eurm81/
My example with shadow-box is here:
Html:
<div id="artist-carousel">
<div class="simple-carousel-window">
<div class="simple-carousel-rail">
#if (Model != null)
{
for (var i = 0; i < 3 * Model.Images.Count; i++) // times 3 due to infinite scrolling
{
var index = i % Model.Images.Count;
<div class="simple-carousel-div" data-index="#(i)" data-link="#Model.NativeImages[index]">
<a class="element">
<img src="#Model.Images[index]" />
</a>
<a class="fullsize">
<img src="~/content/images/carousel-fullsize.png" />
</a>
</div>
if (Model.Images.Count <= 2 && i >= 0) { break; }
}
}
</div>
#if (Model.Images.Count >= 3)
{
<a class="simple-carousel-prev" href="#" data-slide="prev">
<img src="~/content/images/carousel-left.png" /></a>
<a class="simple-carousel-next" href="#" data-slide="next">
<img src="~/content/images/carousel-right.png" /></a>
}
</div>
</div>
CSS:
.simple-carousel-window {
width: 820px;
white-space: nowrap;
overflow: hidden;
position: relative;
display: block;
margin-left: -20px;
box-shadow: inset 0 2px 2px -2px #ebebeb, inset 0 -2px 2px -2px #ebebeb;
line-height: 0;
margin-bottom: 20px;
.simple-carousel-rail {
font-size: 0;
}
.simple-carousel-prev {
position: absolute;
top: 150px;
left: 10px;
display: block;
opacity: 0.8;
}
.simple-carousel-next {
position: absolute;
top: 150px;
right: 10px;
display: block;
opacity: 0.8;
}
.simple-carousel-div {
display: inline-block;
position: relative;
.element {
img {
height: 360px;
float: left;
}
}
.fullsize {
display: block;
opacity: 0.5;
position: absolute;
// centering image
top: 150px;
margin-left: -85px;
left: 50%;
}
}
}

DEMO: http://jsfiddle.net/CXKrh/
HTML
<div>
<img src="http://placekitten.com/100" />
</div>
CSS
div {
width: 300px;
height: 98px;
overflow: visible;
border: 1px solid red;
}
div > img {
height: 100px;
margin-top: -1px;
}
The idea is that the height of the container = image height - border width (top and bottom)
We then apply a negative margin to the images to "bump" the image back over the border.

Related

Add a Link to an Overlay Image

I would like to add a link to an image that has an overlay applied to it. When users hover over the image they get an opaque overlay and text appear. This works great, however I also need users to be able to click that image and taken to a link.
I have pasted my code below - the overlay works but the link portion does not. I believe it's because the overlay is interfering. I tried changing the placement of the link but was unable to do so. I am able to make the '+' be the link, but ideally the entire image should link.
Any thoughts?
JSFiddle
.roomphoto:hover .img__description { transform: translateY(0); }
.roomphoto .img__description_layer { top: 30px; }
.roomphoto:hover .img__description_layer { visibility: visible; opacity: 1; }
.img__description_layer {
position: absolute;
bottom: 0;
left: 0;
right: 0;
color: #cdcbca;
visibility: hidden;
opacity: 0;
display: flex;
align-items: center;
justify-content: center;
transition: opacity .2s, visibility .2s;
}
.roomphoto {
height: 166px;
}
.img__description {
transition: .2s;
transform: translateY(1em);
z-index: 999;
}
.overlay {
position: relative;
}
.overlay:after {
position: absolute;
content:"";
top:0;
left:0;
width:100%;
height:100%;
opacity:0;
}
.overlay:hover:after {
opacity: .8;
}
.blue:after {
background-color: #1a3761;
}
.img__description a {
color: #fff;
}
.roomselect {
clear: both;
float: none;
width: 100%;
max-width: 1000px;
margin: 0px auto;
padding-top: 20px;
}
.roomselect img {
width: 100%;
margin-bottom: -10px;
}
.room3 {
width: 32%;
text-align: left;
float:left;
}
<div class="roomselect"><div class="room3">
<div class="roomphoto overlay blue">
<a href="http://www.google.com">
<img src="https://cdn.mos.cms.futurecdn.net/J9KeYkEZf4HHD5LRGf799N-650-80.jpg" alt="Image Text" />
</a>
<div class="img__description_layer">
<p class="img__description">
<span style="border-radius: 50%; width: 30px; height: 30px; padding: 0px 14px; border: 1px solid #fff; text-align: center; font-size: 36px;">+</span>
</p>
</div>
</div>
</div>
You need to rearrange your html in such a way that when you click on image, you are actually clicking on the anchor tag. I have made some changes to your html, let me know if these work. You might have to increase roomphoto height.
<div class="roomselect">
<div class="room3">
<a href="http://www.google.com">
<div class="roomphoto overlay blue">
<img src="https://cdn.mos.cms.futurecdn.net/J9KeYkEZf4HHD5LRGf799N-650-80.jpg" alt="Image Text" />
<div class="img__description_layer">
<p class="img__description"><span style="border-radius: 50%; width: 30px; height: 30px; padding: 0px 14px; border: 1px solid #fff; text-align: center; font-size: 36px;">+</span></p>
</div>
</div>
</a>
</div>
</div>

Hide/show text on hover

Hello I'm trying to hide / display an absolute positioned text on image hover with transform scale effect and shadowing background I had some problems with z-index and div containers. What I'm trying to achive is:
Before hover:
On hover:
I know I could wrap text into div and then change visibility or display css property on hover but it doesn't work for me. Here is my code:
<div class="container-fluid">
<div class="row">
<div class="col-md-6 col-lg-4 column" *ngFor="let clientProject of clientProjects; let i= index">
<button class="btn button-modal" data-toggle="modal" [attr.data-target]="'#' + i">
<span class="hidden-text">TEXT</span>
<img src="{{clientProject.clickImageButtonPath}}" class="img-fluid image">
</button>
</div>
</div>
</div>
css:
.image {
width: 100%;
height: 400px;
transition: all 0.3s ease-in-out;
z-index: 1;
opacity: 0.35;
}
.button-modal {
padding: 0 !important;
overflow: hidden;
background-color: black;
}
.button-modal:hover {
padding: 0 !important;
}
.hidden-text:hover + .image,
.image:hover {
transform: scale(1.2);
}
.column {
margin: 0 !important;
border: none;
padding: 0 !important;
}
.hidden-text {
display: block;
z-index: 2;
color: white;
font-size: 2rem;
border: none;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
margin: 0;
position: absolute !important;
}
Could someone help with this please?
I'm not sure what you're trying to do exactly, so I think it would be good to figure out what element you want to trigger the action on, then tell that element to hide and show the text. I'm also not sure if you're trying to do this all CSS or not, but I would typically do something like this. Be aware that this is jQuery, which I assume you're using if you're using bootstrap, and this is just an example of what you can do with a simple bit of jQuery code in this example. Here's a link to a working fiddle http://jsfiddle.net/aq9Laaew/110775/ and here's the code I used to achieve the result:
$('.button-modal').hover(function(event){
$(this).find('.hidden-text').show();
},function(){
$(this).find('.hidden-text').hide();
});
jQuery hover handler is actually 2 functions inside, one for mouseover (hover start) and one for mouseout (hover end), and it makes this easy, so you can do one thing on the start (show your text) and another on the end (hide your text) all in a nice little packaged function. You can also split these out and do mouseover and mouseout individually. I would also edit your CSS a little if you're going to use this approach, like this:
.button-modal:hover {
padding: 0 !important;
transform: scale(1.2);
}
.column {
margin: 0 !important;
border: none;
padding: 0 !important;
}
.hidden-text {
display: none;
z-index: 2;
color: white;
font-size: 2rem;
border: none;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
margin: 0;
position: absolute !important;
}
Try this:
<style type="text/stylesheet">
.container:hover #cts {
display: block;
}
</style>
<div class="container">
<div class="img" style="position: absolute; width: 500px; height: 500px; z-index:0;">
<img src="https://i.stack.imgur.com/Az76Y.png"></img>
</div>
<div id="cts" class="text-box" style="display: none; position: absolute; display: table; margin-left: auto; margin-right: auto; background: rgba(0,0,0,0.4); text-align: center; height: 500px; width: 500px; z-index: 1; transition: all .3s ease;">
<div class="text-box-inner" style="display: table-cell; height: 500px; width: 500px; vertical-align: middle; margin-left: auto; margin-right: auto;">
<span class="text" style="color: #fff;">ANY TEXT</span>
</div>
</div>
</div>
<script type="text/javascript">

CSS show a bigger image while hover

Ive got a product page with a smaller image of the product.
Now I want to show a bigger version of this image with a colored background covering the whole page, while I hover the smaller image.
The problem is, that the bigger image flickers while I move the mouse around.
My CSS:
#zoomed-product-img {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(162, 130, 192, 0.8);
z-index: 0;
visibility: hidden;
}
#zoomed-product-img img {
display: block;
margin: auto auto;
}
.productsdetail-image:hover~#zoomed-product-img {
visibility: visible;
}
My HTML:
<div class="productdetails">
<div class="productsdetail-image">
<img src="/assets/images/products/{{page.name}}.png" alt="Produktbild">
</div>
<div class="productsdetail-info">
</div>
<div id="zoomed-product-img">
<img src="/assets/images/products/{{page.name}}.png" alt="Produktbild">
</div>
Can you help me? Maybe my way of thinking is wrong.
I think it flickers because when I show the bigger image, it is above (z index) the small one and I am not hovering the image anymore so it disappears.
I would also love to solve this with javascript, if you can give me any advice.
You need to specify dimensions for the container of the image. This is why it is flickering. I also used display: none; and display:block to hide and show the images.
.productdetails {
position: relative;
}
#zoomed-product-img {
display: none;
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: -1;
}
/* This is the product detail image styles */
.productsdetail-image {
display: block;
height: 200px;
width: 200px;
}
.productsdetail-image:hover img {
display: none;
}
.productsdetail-image:hover + #zoomed-product-img {
display: block;
}
HTML
<div class="productdetails">
<div class="productsdetail-image">
<img src="https://placeimg.com/200/200/animals" alt="Produktbild">
</div>
<div id="zoomed-product-img">
<img src="https://placeimg.com/300/300/animals" alt="Produktbild">
</div>
<div class="productsdetail-info">
</div>
Demo:
http://jsfiddle.net/n07bt46y/
Please check this in full page
$(document).ready(function(){
$('.productsdetail-image img').hover(function() {
$(this).hide();
$('#zoomed-product-img ').show(500);
});
$('#zoomed-product-img .close').click(function(){
$(this).parent().hide();
$('.productsdetail-image img ').show();
});
});
.productsdetail-image img {
width: 150px;
height: auto;
transition: all 0.5s ease;
}
#zoomed-product-img {
display: none;
position: absolute;
width: 100%;
height: 100%;
background-color: red;
}
#zoomed-product-img span.close {
position: absolute;
color: #fff;
cursor: pointer;
top: 20px;
right: 20px;
}
#zoomed-product-img img {
position: absolute;
width: 300px;
height: auto;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: aUto;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="productdetails">
<div class="productsdetail-image">
<img src="https://placeimg.com/300/300/animals" alt="Produktbild">
</div>
<div id="zoomed-product-img">
<span class="close">close</span>
<img class="zoom-img" src="https://placeimg.com/300/300/animals" alt="Produktbild">
</div>
<div class="productsdetail-info">
</div>
Are you wanna build something like that? Hoppefully that fiddle can help you

Cannot set overflow-x visible and overflow-y auto

First of all, I know this question has been asked before. But I couldn't find the right solution for my case. That is why, I am posting it again.
So I am having a side bar
<div className="LeftMenu">
<div style={{position:relative"}}>
<div className= "icon-Back-office-icons_Logout1"}/>
<span className="tooltiptext">Name 1</span>
</div>
<div style={{position:relative"}}>
<div className= "icon-Back-office-icons_Logout2"}/>
<span className="tooltiptext">Name2</span>
</div>
</div>
.LeftMenu {
background-color: white; // box-shadow: 1px 2px 9px 0 rgba(92, 131, 205, 0.06);
display: flex;
align-items: center;
flex-direction: column;
padding-top: 24px;
padding-bottom: 25px;
height: 100%;
z-index: 100;
width: 100px;
position: fixed;
overflow-x: visible;
overflow-y:auto;
}
.tooltiptext:hover {
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
top: -5px;
left: 110%;
}
.tooltiptext::after {
content: "";
position: absolute;
top: 50%;
right: 100%;
margin-top: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent black transparent transparent;
}
The leftmenu div contains many children div. On hovering each child element a tool tip is displayed. A vertical scroll must be displayed if the length of children div increases. Hence I have given overflow-y auto. But the tooltip must be visible, and it has to overflow the leftmenu. Hence, I am giving overflow-x as visible.
But this doesn't work as I thought.
https://jsfiddle.net/jcj7k6kp/ Here is a jsfiddle that demonstrates my issue.
I don't think it's possible with only css. So here is a possible javascript solution (maybe you'll need to tweak some stuff to have px perfect centring ...):
const tooltips = Array.from(document.querySelectorAll('.tooltip'));
function displayTooltip(e) {
let tooltip = e.target;
let title = tooltip.getAttribute('data-title');
let tooltiptext = document.getElementById('tooltiptext');
let rect = tooltip.getBoundingClientRect();
let tooltipMargin = 14;
tooltiptext.innerHTML = title;
tooltiptext.style.top = rect.y + 'px';
tooltiptext.style.left = rect.x + rect.width + tooltipMargin + 'px';
tooltiptext.style.display = 'block';
}
function hideTooltip() {
let tooltiptext = document.getElementById('tooltiptext');
tooltiptext.style.display = 'none';
}
tooltips.forEach(function(t) {
t.addEventListener('mouseover', displayTooltip);
t.addEventListener('mouseout', hideTooltip);
});
.content {
height: 400px;
}
.LeftMenu {
width: 200px;
background-color: white;
box-shadow: 1px 0 0 0 #ebedf8, -6px 0 30px 0 rgba(42, 34, 64, 0.1);
display: flex;
align-items: center;
flex-direction: column;
padding-top: 24px;
padding-bottom: 25px;
position: fixed;
height: 100px;
z-index: 100;
overflow-x: hidden;
overflow-y: auto;
}
/*overflow-x and overflow-y isn't working as expected*/
/*overflow-x must be visible since I need the tooltip to be visible*/
/*overflow-y must be auto since I need to have a fixed height div and content must be scrollable if it doesnt't fit inside the fixed height*/
.tooltip {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
}
.tooltiptext {
position: absolute;
display: none;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
z-index: 1000;
}
.tooltiptext::after {
content: "";
position: absolute;
top: 50%;
right: 100%;
margin-top: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent black transparent transparent;
}
<div class='tooltiptext' id='tooltiptext'>
</div>
<div class="LeftMenu">
<div class="tooltip" data-title="Tooltip text">
Hover over me
</div>
<div class="tooltip" data-title="Tooltip text 2">
Hover over me 2
</div>
<div class="tooltip" data-title="Tooltip text 3">
Hover over me 3
</div>
<div class="tooltip" data-title="Tooltip text 4">
Hover over me 4
</div>
<div class="tooltip" data-title="Tooltip text 5">
Hover over me 5
</div>
<div class="tooltip" data-title="Tooltip text 6">
Hover over me 6
</div>
<div class="tooltip" data-title="Tooltip text 7">
Hover over me 7
</div>
<div class="tooltip" data-title="Tooltip text 8">
Hover over me 8
</div>
</div>
and a jsfiddle

FF rendering position relative different than all other browsers

My website, http://dev.markzanghi.com, is rendering incorrectly in firefox and i don't know why.
Every other browser, including IE renders it correctly. The link above will display the mistake. Basically, i need two parts to my header for an animation. Below is my CSS
/*
TOP BAR
*/
.topbar {
height: 75px;
background: url('../img/headerBGtop.png') repeat-x;
}
.bottomTopBar {
background: url('../img/headerBGbottom.png') repeat-x;
height: 6px;
position: relative;
top: 64px;
}
.topbar .headerWrapper {
max-width: 924px;
margin: 0 auto;
padding: 0 5px;
}
.bottomHeader {
position: relative;
top: -11px;
left: 0px;
z-index: 1;
}
.headerArrowImg {
width: 924px;
overflow: hidden;
}
.bottomFiller {
position: relative;
top: -24px;
background: url(/img/headerBGbottom);
height: 11px;
}
#leftBottomHeader {
}
#rightBottomHeader {
top: -35px;
}
.logo {
float: left;
margin-top: 13px;
}
.logo img {
height: 55px;
}
.topbarLinks {
float: right;
text-decoration: none;
position: relative;
top: 44px;
z-index: 10;
}
.topbarLinks a{
color: white;
margin-left:25px;
padding: 10px 0px;
}
.topbar .headerArrowImg img {
max-width: none;
position: relative;
left: -200px;
}
And the HTML:
<header>
<div class="topbar navbar-fixed-top" >
<div class="headerWrapper">
<div class="logo">
<img src="img/homeLogo.png" />
</div>
<div class="topbarLinks">
<a id="workLink" href="#"><img src="img/workLink.png" /></a>
<a id="aboutLink" href="#/about"><img src="img/aboutLink.png" /></a>
<a id="contactLink" href="#/contact"><img src="img/contactLink.png" /></a>
</div>
<div id="bottomHeaderWrap" class="bottomHeader">
<div class="headerArrowImg">
<div id="arrowImgWrapper">
<img src="/img/headerArrowImg.png" />
</div>
</div>
</div>
</div>
<div id="leftBottomHeader" class="bottomFiller">
</div>
<div id="rightBottomHeader" class="bottomFiller">
</div>
</div>
</header>
If anyone has any idea why this is not working, please let me know!
Thanks in advance.
I had the same issue with a menu animation a while back.
The "problem" is that Firefox requires an explicit declaration of both X & Y coordinates when one is declared. On several items you have declared a top (Y), but you have not declared a left or right (X).
Add a left:0 or something and you should be fine. Or, since they are position:relative, you could just convert top to margin-top.