Click on button underneath a container that covers it - html

I am trying to make it so that the review button underneath the chat overlay container can be clicked when the chat overlay container is on top. The size of the chat overlay container can't be changed. I have tried with stacking options z-index. I thought about the CSS option pointer-events but the x in the top right and the circle chat button needs to remain clickable. Any help is much appreciated thanks.
The following is an image in inspector with the chat overlay container highlighted.
The following is simplified version of how the html is structured for the chat overlay and the card container.
<div class="card">
<p class="title">example.com</p>
<button class="review">Review</button>
</div>
<div class="overlay">
<div class=help-text>
<button class="dismiss-help">X</button>
<p>Got any questions....</p>
</div>
<span class="overlay-launcher">
<button class="launcher-button">Circle</button>
</span>
</div>

I would continue exploring the use of pointer-events.
pointer-events is an inherited property, so if a value isn't explicitly set, it will inherit the computed value from it's parent.
Try pointer-events: none on the chat overlay, but pointer-events: auto on the children that should remain clickable. eg close button and toggle chat button (or one of their common ancestors).
// Not required. Only here to demonstrate click events
document
.querySelectorAll('button')
.forEach(button =>
{
button.addEventListener('click', (e) =>
{
console.log(`clicked ${e.currentTarget.textContent.trim()}`)
})
})
.overlay {
background : rgba(128, 128, 128, 0.5);
position : absolute;
top : 0;
pointer-events : none;
outline : 1px solid blue;
}
.overlay button {
pointer-events : auto;
}
<div class="card">
<p class="title">example.com</p>
<button class="review">Review</button>
</div>
<div class="overlay">
<div class=help-text>
<button>X</button>
<p>Got any questions....</p>
</div>
<span class="overlay-launcher">
<button class="launcher-button">Circle</button>
</span>
</div>

z-index and position:relative help the ".help-text",".launcher-button" classes to stay on top of other contents.
.overlay{
display:flex;
flex-direction:column;
align-items:end;
width:fit-content;
}
.help-text{
background:white;
width:fit-content;
box-shadow: 1px 1px 5px;
border-radius: 5px;
display:flex;
flex-direction:column;
align-items:end;
z-index:1;
position:relative;
/* z-index and position:relative help .help-text to stay on top of other contents */
}
.help-text>p{
font-family:sans-serif;
}
.dismiss-help{
background-color:transparent;
border:none;
}
.launcher-button{
width:3rem;
aspect-ratio:1;
border-radius:50%;
border:none;
background-image:linear-gradient(to left,rgba(0,100,180,1) 30%,rgba(0,0,255,1));
margin-top:1rem;
z-index:1;
position:relative;
/* z-index and position:relative help launcher button to stay on top of other contents */
}
#samplebtn{
position:absolute;
top:40%;
left:90px;
height:2rem;
}
<div class="overlay">
<div class=help-text>
<button class="dismiss-help">X</button>
<p>Got any questions....</p>
</div>
<span class="overlay-launcher">
<button class="launcher-button">Circle</button>
</span>
</div>
<button id="samplebtn">Review
</button>

Related

Checkbox alignment inside div

I want to put checkbox inside a div tag. I want to create like
but the result that I get was like
the checkbox position should be at the right.
Create a containing div, then add three floating divs, one per element; Media element, text element, then check box. clear your float within the containing div. Place the check box in the far left div. Adjust CSS as needed.
Here is a working fiddle Check out the fiddle
#media_cont {
height:200px;
box-shadow:0px 0px 5px #000;
border-radius:10px;
padding:5px;
}
.media_content {
float:left;
width:33%;
text-align:center;
}
#checkbox {
margin-top:15%;
}
.clear {
clear:both;
}
.container {
padding-top:10px;
}
<div id="media_cont">
<div class="media_content"><img src="#" width="200" height="200"></div>
<div class="media_content">
<div>
<h2 class="header">
John Doe
</h2>
<h4 class="header">
User Profile 1
</h4>
</div>
</div>
<div id="checkbox" class="media_content"><input type="checkbox" checked></div>
<div class="clear"></div>
<div class="container">
<p>
New section
</p>
</div>
</div>
UPDATE: If you wish to have the check box clicked, simply add some JQuery such as the following:
$(document).ready(function() {
$("#profile").click(function() {
$('input[type="checkbox"]').attr("checked", "checked");
});
});
Then add the call id profile to your containing divs class.
<div id="profile" class="profile">
Here is an updated fiddle:
Click inside div and append checked into input field
Try the following:
.myDiv{
position: relative;
}
.myCheckbox {
position: absolute:
top: 50px; /* you compute this properly */
right: 15px; /* you compute this properly */
}
use awesome bootstrap checkbox
http://flatlogic.github.io/awesome-bootstrap-checkbox/demo/

Show element on hover another using css

I'm working on a tiny css action which based on A element hover, will display another element. The code is pretty basic:
<a title="#" class="portfolio-reaction" href="#">
<img src="http://i.imgur.com/OZb7SI8.png" class="attachment-grid-feat" />
<div class="headline-overlay">LOREM IPSUM</div>
</a>
.portfolio-reaction {
width:250px;
height:250px;
display:block;
}
.headline-overlay {
background:none;
height:100%;
width:100%;
display:none;
position:absolute;
top:10%;
z-index:999;
text-align:left;
padding-left:0.5em;
font-weight:bold;
font-size:1.3em;
color:#000;
}
.attachment-grid-feat:hover ~ .headline-overlay {
display:block;
}
and jsfiddle: https://jsfiddle.net/yL231zsk/1/
This solution works in 99%. The missing percent is the effect - while moving mouse arrow through the button, text is blinking. I have no idea why. Secondly - what if I want to extend number of appearing elements from 1 to 3. So to have:
<a title="#" class="portfolio-reaction" href="#">
<img src="http://i.imgur.com/OZb7SI8.png" class="attachment-grid-feat" />
<div class="headline-overlay">
<p class="element-1">abc</p>
<p class="element-2">111</p>
<div class="element-3">X</div>
</div>
</a>
Thank you for any tips and advices.
You wrote the following in your css file :
.attachment-grid-feat:hover ~ .headline-overlay {
display:block;
}
It won't work since .attachment-grid-feat isn't the parent of .headline-overlay. So it won't select the state when the parent is selected because there are no element .healine-overlay inside .attachment-grid-feat. Also no need to add ~ between the two. The right selector is the following :
.portfolio-reaction:hover .headline-overlay {
display: block;
}
This way you are targeting the child div .healine-overlay when parent div .portfolio-reaction (you might want to make the <a> tag a <div> tag) is hovered.
.portfolio-reaction {
width: 250px;
height: 250px;
display: block;
}
.headline-overlay {
background: none;
display: none;
position: absolute;
top: 10%;
z-index: 999;
text-align: left;
padding-left: 0.5em;
font-weight: bold;
font-size: 1.3em;
color: #000;
}
.portfolio-reaction:hover .headline-overlay {
display: block;
}
<div title="#" class="portfolio-reaction" href="#">
<img src="http://i.imgur.com/OZb7SI8.png" class="attachment-grid-feat" />
<div class="headline-overlay">
<div id="element-1">Hello 1</div>
<div id="element-2">Hello 2</div>
<div id="element-3">Hello 3</div>
</div>
</div>
In this code snippet, three elements are contained inside .headline-overlay. On hover, all three elements are displayed.
First, change the last CSS line from this:
.attachment-grid-feat:hover ~ .headline-overlay {
display:block;
}
into this:
.attachment-grid-feat:hover .headline-overlay {
display:block;
}
And will "half" work. You need after to change the width and height of your <div class="headline-overlay"> from a smaller percentage to match your square width and height(leaving it to 100% covers the entire screen, and as a result, the text wont dissapear, no matter where you will move the cursor). Or, If you want your <div> element to match automaticaly the square size, then you leave the width and height unchanged and change only his position:absolute into position:relative and of course, a little adjusting his position from top.
Here is a working fiddle: https://jsfiddle.net/yL231zsk/9/

How to make a hover effect remain?

I have a stack of buttons that, when hovered upon, make a text box appear on the right side of the stack. The purpose of the text box is to be a scroll box, but in order to do that, I need to be able to scroll. Unfortunately, when I take my mouse off the button TO scroll that box, the box goes away because my mouse is no longer on the button to "activate" it.
You can see the live example on my page here. Scroll down to the "Commissions" box on the left and you will see it.
I'm looking to get more of the effect that the one on this page shows in "Art Info".
Here is the CSS code:
*{background:white; border:none; padding:0; margin:0;}
.gr{padding:0 !important;}
.gr-top img, .gr1, .gr2, .gr3 {display:none;}
.gr-top, .bottom, a.external:after, .left br {display:none;}
a{text-decoration:none; font-weight:normal;}
.external{display:block;}
h1{
font-family:Times;
text-align:center;
font-size:18px;
color: #83d4cc;
font-style: italic;
letter-spacing: 3px;
line-height:10px;
}
h2{
font-family:Times;
text-align:center;
font-size:13px;
color: #252424;
font-style: italic;}
.gr-box{
z-index:99!important;
font-family:Times;
text-align:center;
font-size:13px;}
.text{
position:relative;
margin:10px 10% 10px 10%;}
.left{width:180px;}
.textbox{
display:none;
width:276px;
height:276px;
margin-top:32px;
position:absolute;
overflow:scroll;
background: #83d4cc;
left:210px;
color: #ffffff;
top:0;}
.wrap:hover .textbox{display:inline-block;}
.button{
display:block;
color: #FFFFFF;
background: #252424;
border-radius:0px;
padding:9px 0px;
margin-bottom:4px;}
.button:hover{
color: #FFFFFF;
background: #83d4cc;
}
.button span{
display:none;
font-size:0.85em;}
.button:hover span{display:inline;}
Here is the HTML code:
<div class="left"><h1>Commissions</h1><h2>Hover for more information</h2><div class="wrap"><a class="button" href="http://gracefuleigh.deviantart.com/gallery/48200599">Manipulations</a><div class="textbox"><div class="lmf"></div>Manipulations textbox</div></div><div class="wrap"><a class="button" href="http://gracefuleigh.deviantart.com/gallery/47299585">Howrse Layouts</a><div class="textbox"><div class="lmf"></div>Howrse Layouts textbox</div></div><div class="wrap"><a class="button" href="http://gracefuleigh.deviantart.com/gallery/49118216">Gallery Directories</a><div class="textbox"><div class="lmf"></div>Gallery Directories textbox</div></div><div class="wrap"><a class="button" href="http://gracefuleigh.deviantart.com/gallery/48666470">Journal Skins</a><div class="textbox"><div class="lmf"></div>Journal Skin textbox</div></div><div class="wrap"><a class="button" href="http://gracefuleigh.deviantart.com/gallery/47299612">Banners</a><div class="textbox"><div class="lmf"></div>Banners textbox</div></div><div class="wrap"><a class="button" href="http://gracefuleigh.deviantart.com/gallery/48200600">Stamps & Icons</a><div class="textbox"><div class="lmf"></div>Stamps & Icons textbox</div></div><div class="wrap"><a class="button" href="http://gracefuleigh.deviantart.com/gallery/49118169">Folder Menus</a><div class="textbox"><div class="lmf"></div>Folder Menus textbox</div></div> <div class="wrap"><a class="button" href="">Other</a><div class="textbox"><div class="lmf"> </div> Other textbox </div></div> <h2>Page design by :devgracefuleigh:</h2> </div> <div class="clear"></div>
Thank you so much for the help, in advance!
- Leigh
You can use jquery fadeIn to make the textBox appear (see http://api.jquery.com/fadein/) with the onmouseover event, then have an icon or link to close the text box when the user is finished.
I hope this this fiddle can help you out http://jsfiddle.net/S7EjW/
The element which is appearing on hover needs to be inside the element which is hovered, else when the mouse moves out it triggers the mouseleave event which fades the element off.
HTML
<div class="element">
<span class="title">Hover Me to see info.</span>
<span class="info">This is a sample info span that appears on hovering the title.</span>
</div>
JS
$(".element").hover(function(){
$(this).find(".info").fadeIn(500);
}, function(){
$(this).find(".info").fadeOut(500);
});
Fiddle Link : http://jsfiddle.net/z3EML/
To make hover effect remain, you need to use Javascript or jQuery.
On hovering of element, you'll add the class to the element which you need to show.
Like this :
HTML :
<div class="menu">
Hover
</div>
<div class="textbox">
<input type="text"/>
</div>
CSS :
.menu{
float:left;
}
.show_textbox{
background:#dadada;
padding:5px;
color:#000;
text-decoration:none;
}
.textbox{
float:left;
display:none;
margin-left:5px;
}
.show{
display:block!important;
}
JS :
$(document).ready(function(){
$('.show_textbox').hover(function(){
$('.textbox').addClass('show');
});
});
This jQuery will add the .show class to the element when it is hovered. You can add CSS properties to .show which you need to add in hover state.
It'll keep the hover state until the page is refreshed.
I couldn't comment, so im answering you question with what i know off the top of my head.
look into CSS3, there is an operator ">" that you should become familiar with

Pushing a div inside a div to the very bottom that works with IE7

I'm running in to a slight problem where I am not able to align and get the same effect I get from chrome in IE7. What I am trying to accomplish is to push a div with a background to the bottom of a container div.
JS Fiddle : http://jsfiddle.net/mn34r/
Code
<div class="container">
<img style="padding-top:20px; padding-bottom:20px" src="img/img.png">
<div class="description"><br>
<span style="font-weight:bold;font-size:15px;">Harry's Nose</span><br>
<button class="btn btn-small btn-primary" type="button"><i style="color:#fff;
</i>Read More</button>
</div>
</div>
css:
.container{
border:solid 1px #e2e2e2;
height:327px;
text-align:center;
position:relative;
}
.description{
height:110px;
background-color:#F1F1F1;
text-align:center;
bottom:0;
width:100%;
position:absolute
}
Any help would be greatly appreciated.
Thank you.
In IE7 top: overwrites bottom:, so you need to use an IE6/7 hack with CSS expressions.
#forceBottom {
position:absolute;
top:expression(
document.documentElement.scrollTop +
document.documentElement.clientHeight -
this.clientHeight
);
}

Z-index in IE9 Error

I'm currently working on a site, and I am having problems with two images not displaying correctly. IE 9 is the only browser I'm having problems with, so I just need some help. I'm working on a slideshow that has a shadow background to it. At the ends of the slideshow I'm attempting to just create two clickable divs that are transparent so I can move the slideshow back and forth. But the shadow background image is being layered on top of the transparent divs, and covering all but the extreme edges of the divs, whenever the cursor changes to a pointer is when you're over the divs.
<div id="HomeCarousel">
<div id="slideshow">
<div id="slideshow-area">
<div id="slideshow-shadow"><img src="#ACCOUNTRESOURCES/BannerOverlay.png" /></div>
<div id="slideshow-container">
<div id="slideshow-scroller">
<div id="slideshow-holder">
<div class="slideshow-content" id="slide0">
<img name="image0" src="#ACCOUNTRESOURCES/Orange.png"/>
</div>
<div class="slideshow-content" id="slide1">
<img name="image1" src="#ACCOUNTRESOURCES/Green.png"/>
</div>
<div class="slideshow-content" id="slide2">
<img name="image2" src="#ACCOUNTRESOURCES/Blue.png"/>
</div>
</div>
</div>
</div>
</div>
<div id="click">
<div id="left-arrow"></div>
<div id="right-arrow" ></div>
</div>
</div>
</div>
This is my html layout, #slideshow-area and #left-arrow,#right-arrow are the elements I'm having a problem with.
#slideshow {
position:relative;
}
#slideshow-area {
position:absolute;
left:35px;
width:910px;
height:279px;
}
#slideshow-shadow {
position:absolute;
width:966px;
top:-22px;
left:-28px;
z-index:2;
}
#slideshow-container {
position:absolute;
overflow:hidden;
width:910px;
height:279px;
}
.slideshow-content {
width:910px;
height:279px;
}
#click {
position:relative;
position:absolute;
z-index:4;
}
#left-arrow, #right-arrow {
height:279px;
width:35px;
position:absolute;
top:22px;
z-index:3;
}
#left-arrow {
left:0px;
cursor:pointer;
}
#right-arrow {
left:945px;
cursor:pointer;
}
That is my CSS, as far as I know I'm doing things correctly, just IE 9 is not displaying it. Does anybody know anything I could do to fix this? Here's the website if you need it.
Thanks,
Morgan
div#click has no height; it is a 980x0px element since it does not contain a non-floated, non-positioned element. Define height on this element and the arrows contained in it will work as expected.