Removing a div or a class affect another div - html

As a beginner this bug seems pretty strange and since i can't put all code here(large) I will be happy to even hear where to begin.
If more code needed I will provide.
I have this :
<div class="labeledInput">
<label class="font">Tap To Add Your Photo:</label>
<div class="imagePreview logoPreview" id="logoPreview" style="background-image: url(images/Holder.png);">
<input type="file" id="logoPreview">
</div>
</div>
If I remove this row (and only this) :
<div class="imagePreview logoPreview" id="logoPreview" style="background-image: url(images/logoHolder.png);">
or even remove the class imagePreview from it, or set it without a class at all:
<div class="logoPreview" id="logoPreview" style="background-image: url(images/logoHolder.png);">
Then another button that is far away , turns to be a file upload button when clicked, instead of just a button that scroll (using JS) when clicked.
This is the affected button(not related at all to the code above) :
<div class="nextButton">
<input type="image" src="https://picsum.photos/50/50" onclick='nextButton()'/>
</div>
EDIT :
I found that in my CSS, if I remove this style - the bug will not happen :
.imagePreview img
{
max-width: 100%;
pointer-events: none;
}
//***** this one if removed solve the problem but make an ugly button*****
[type="file"] {
cursor: pointer;
opacity: 0;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}

add position as relative to parent class
.imagePreview{
position: relative;
}

Related

CSS translateX(100%) on <input> in a parent with overflow causes 'flickering' and inconsistent width

What i'm trying to achieve
example of the closed version /
example of the opened version
At the top of the page in a 'fixed' header, i have a 'search' button next to a 'toggle' for the main menu. The header-search div (magnifying glass) is positioned next to the menu toggler (green). A form is currently positioned 'absolute' within the header to take up the full width of the header minus the padding on each side and its controls (search and toggler) as follows:
styles from header
.header {
top: 0;
left: 0;
width: 100%;
position: fixed;
background-color: var(--color-primary-700);
}
styles from header__aux
.header__aux {
display: flex;
column-gap: 1rem;
flex-flow: nowrap row;
}
.header-search {
display: block;
position: static;
}
.header-search__form {
top: 1.5rem;
height: 4rem;
overflow: hidden;
position: absolute;
left: var(--g-gutter);
width: calc(100% - (7rem + (var(--g-gutter)*2)));
}
.header-search__form-label {
top: -99.9rem;
left: -99.9rem;
color: inherit;
position: absolute;
}
.header-search__form.is-active
.header-search__form-input {
transform: translateX(0%);
}
.header-search__form-input {
width: 100%;
height: 4rem;
padding: 0 1.2em;
transform: translateX(100%);
border: .2rem solid #8097b3;
border-top-left-radius: 2rem;
border-bottom-left-radius: 2rem;
transition: transform 1s ease-in-out
background-color: var(--color-primary-700);
}
A input field inside this form is given 100% width and then using transform: translateX(100%) pushed completely to the right outside the overflow of the form (which retains it's width as set above). When a user presses the 'search' button a class is-active sets this transform: translateX(100%) to 0 and the input field should slide (from the right) to it's original position 100% of the width as seen in this image.
What this looks like in HTML
<header class="header section">
<div class="header__container container">
<a class="header__brand" href="#" aria-label="x">
<!-- svg brand -->
</a>
<div class="header__navs" id="headerNavs">
<div class="header__mask">
<ul id="headerMenu" class="header-menu">
</ul> <div class="header__langs header-langs">
Language
</div>
</div>
</div>
<div class="header__aux">
<div class="header__search header-search">
<button aria-label="Open of sluit het invoerveld voor een zoekopdracht" class="header-search__toggle" id="headerSearchToggle" aria-pressed="false" role="button" tabindex="0">
<i id="headerSearchIcon" class="far fa-search"></i>
</button>
<form class="header-search__form" action="/" id="headerSearchForm" role="search" method="get">
<label class="header-search__form-label" for="headerSearchInput">Zoeken</label>
<div class="header-search__form-slide">
<input placeholder="Zoeken …" required="" class="header-search__form-input" id="headerSearchInput" minlength="2" type="search" value="" name="s">
</div>
</form>
</div>
<a aria-label="" class="header__toggle header-toggle" aria-controls="headerNavs" aria-expanded="false" id="headerToggle" href="#">
Toggle
</a>
</div>
</div>
</header>
The problem
When opening the 'search' the input immediately jumps to the end of the animation which is seen in the example of the opened version (top) and then continues moving left, constantly correcting it's position back to what is seen in the image causing a weird 'flickering' effect usually in this position. Sliding the input 'back' to the right works perfectly.. What's even weirder is that it sometimes does work correctly for a few attempts once i've been on the page for a while. Then suddenly it breaks again.
What i've tried
Different types of browsers, including checking it on my own mobile device (not in the dev tools)
Giving the input the same fixed width as the parent
Removing a translateY on the parent and reverting to 'top' top position it in the vertical center
Adding 1 or multiple parents to the input to force it to inherit that width
As mentioned in a comment, adding transform:translateZ(0.1px); to force rendering using the GPU
What works, but i can't explain
Removing the overflow on the parent form element works and allows the animation to play smoothly, but that shows the input behind the element as seen in this image
I can think of some ways to make this look better, but i just really want to know what i'm missing. I believe i've done these types of simple animations 1000s of times now. A parent with overflow, hiding a child that's translated over.. or perhaps i'm mistaken. Hopefully someone can make sense of this - many thanks if you've taken the time to do so :)

How do I remove the zoom icon that appears when hovering over image?

I'm working on a site that uses this bootstrap theme. When the mouse hovers over any image a zoom icon appears - how do I remove it?
I have tried removing class="zoomIcon" and looked on this site as well as searching on Google.
HTML:
<div class="product-main-image-container">
<img src="../../images/products/prod1.png" alt="" class="product-loader" style="display: none;">
<span class="thumbnail product-main-image" style="position: relative; overflow: hidden;">
<img src="../../images/products/prod1.png" alt="">
<img src="../../images/products/prod1.png" class="zoomImg"
style="position: absolute; top: -0.0456852791878173px; left: -1.23350253807107px; opacity: 0; width: 400px; height: 400px; border: none; max-width: none; max-height: none;">
</span>
</div>
You can add this to your CSS:
<style>
img:hover {
cursor: default;
}
</style>
I hope this helped you!
You can override this cursor behavior by either modifying the CSS that is making it happen (it looks like a CSS file called style.css) or by writing your own rule to make it stop.
The rule is on .product-main-image in line 432 of the style.css file, and to overwrite it, you would need a rule like this:
.product-main-image{cursor:default;} or any other cursor style you wish
class product-main-image has the zoom icon:
.product-main-image{
cursor: zoom-in; cursor: -webkit-zoom-in; cursor: -moz-zoom-in
}
http://screencast.com/t/NcdCxnrrW4
Just remove this class from the span or change the cursor on this class to something else http://www.w3schools.com/cssref/pr_class_cursor.asp
This is not from a class.
img:hover{
cursor:pointer;
}
Source : https://developer.mozilla.org/en-US/docs/Web/CSS/cursor1
Unrelated : You shouldn't leave the 'alt' tags empty, they are important to accessibility and SEO.
You can use the CSS cursor property.
Then you can just assign it to default on hover
img:hover {
cursor: default;
}

Make a HTML image "click-see-through"

I have an image, and on top of that image is another smaller image. When the first image is clicked, the second one appears, and it disappears when the first image is clicked again. My problem is when the second image appears over the first one, it makes the area that it covers of the first image unclickable. Is it possible to make it so the first image can be clicked through the second image?
This is the HTML for the second image (it's generated in PHP):
Echo '<img src="images/tick.png" id="tick' . $i .'" class="hidden" style="position: absolute; top: 0px; left: 70%;"/>';
Simply put both images in a container div, and attach the click event handler to that instead of the bigger image. This way you can simply make use of event bubbling (which isn't available on the bigger image since it cannot have child elements, such as the smaller image).
Find a working solution here:
https://jsfiddle.net/6nnwy3xw/
$(document).ready(function() {
$('.imgcontainer').on('click', function() {
$(this).toggleClass('toggleImg');
});
})
.imgcontainer {
height: 300px;
width: 300px;
position: relative;
}
.imgcontainer img:first-child {
display: block;
height: 300px;
width: 300px;
}
.imgcontainer img+img {
position: absolute;
top: 50px;
left: 50px;
opacity: 0;
transition-duration: 0.3s;
}
.imgcontainer.toggleImg img+img {
opacity: 1;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="imgcontainer">
<img src="http://lorempixel.com/300/300" />
<img src="http://lorempixel.com/200/200" />
</div>
I'm assuming your use-case is some kind of checkbox replacement element? In this case, this may also be of interest to you:
Use images like checkboxes
If that is the case, I'd make the surrounding diva label instead, so it also automatically checks your (probably hidden) real checkbox.
If I understand the issue you're describing properly, you could try turning pointer-events off for the second image, that is often displayed over the click-target:
.two { pointer-events: none; }
Note that this is only supported with HTML in Internet Explorer 11 and up (as well as in Chrome and Firefox). For SVG, support was available in IE 9. That may suffice for a work-around if needed.
Fiddle: http://jsfiddle.net/tbqxjp19/
For better support you should move your handler to an element that will not be obstructed, and as such will always work to toggle the visibility of the second image:
<div class="images">
<img src="http://placehold.it/100x100" class="one" />
<img src="http://placehold.it/100x100/000000" class="two" />
</div>
document.querySelector( ".images" ).addEventListener( "click", function () {
this.classList.toggle( "toggled" );
});
The above simply binds a handler to click events on the .images container, toggling a class that will hide and/or reveal the second image, given the following:
.toggled .two {
opacity: .1;
}
Fiddle: http://jsfiddle.net/tbqxjp19/1/
Try this , if you are fine with jquery solution.
HTML
<img src="images/large.png" class ="image" id="image1" style="position: absolute; top: 0px; left: 0px;" />
<img src="images/small.png" id="image2" class ="image" style="position: absolute; top: 0px; left: 0px; z-index:10;" />
css
.hiddenimage{
display:none;
}
JQuery
$(".image").click(function(){
("#image2").toggleClass("hiddenimage");
})

How to highlight a div with children (with partial opacity layer?) Like Yahoo mail, see pic

In Yahoo mail, when you are writing an email and you drag a file onto the page and hover, the message area becomes highlighted. It can be seen here:
The part of this that I don't get is how to have the blue area appear with partial opacity over the things under it that are normally visible.
With:
#blueBox {
background-color: #FFD090;
opacity: 0.0;
}
If the msgContent is a child of blueBox:
<div id='msgBox'>
<div id='blueBox'>
<div id='msgContent'>
... all the message contents, buttons, etc.
</div>
</div>
</div>
and when msgBox is hovered I increase blueBox opacity from 0 to say 0.6, the blueBox will show but the msgContent div is hidden until the hover event. It should be visible always.
If the msgContent div is not a child of blueBox, then the blueBox doesn't cover it.
I've tried rgba (http://jsfiddle.net/mkasson/nJcxQ/19/) like here on SO, but it doesn't cover over the child elements.
Couldn't do my usual watching/inspecting via browser's webdev tools because focus was never on the browser while dragging the file onto it.
Thanks!
Here is how I would go about this,
(What the problem is, you are using the parents background. You can't make the parents background go over it's content, that is not what a background does. It merely sites behind everything it is containing and acts as a background.)
html,
<div class="messageContent">
<span class="overlay"></span>
<p>Darn fanatically far and tarantula jeepers meek a secret much so hence underneath monogamously interwove apart gosh spilled far where and badger.</p>
This is a link
</div>
css,
.messageContent {
color: #000;
position: relative;
height: 100%;
width: 100%;
}
.overlay {
position: absolute;
top: 0;
left: 0;
background: lightBlue;
opacity: 0;
height: 100%;
width: 100%;
display: block;
z-index: 100;
}
.messageContent:hover .overlay {
opacity: 0.6;
}
What I am doing is placing an absolute span tag inside of the parent to act as the color overlay. When the parent is hovered the overlay child will become active by increasing it's opacity.
JSFIDDLE
Here's how I would do it.
<div id='msgBox'>
<div id='blueBox'>
</div>
<div id='msgContent'>
... all the message contents, buttons, etc.
</div>
</div>
CSS
#blueBox {
background-color: #FFD090;
opacity: 0.0;
position: absolute;
top: 0;
left: 0;
}
jQuery
$("#msgBox").hover(function(){
$("#blueBox").css({top:$(this).css("top")}).height($(this).outerHeight()).width($(this).outerWidth()).animate({opacity:0.6});
},function(){
$("#blueBox").animate({opacity:0}).height(0).width(0);
});
http://jsfiddle.net/54cx7/2/
The problem is that since content is a child of bluebox, then it inherits the 0 opacity.

setting opacity with css :hover doesn't work for child element

I am trying to make a link appear when the mouse is hovered above a div, but i can't get it to work.
HTML:
<div class="rendezvous" style="position: relative">
<img src="http://placehold.it/50x50" />
<div class="remover" style="width: 32px; position: absolute; top: 0px; left: 15px; opacity: 0;">
Link
</div>
</div>
CSS:
.rendezvous:hover .remover {
opacity: 0.5;
}
JSFiddle: http://jsfiddle.net/6uLTr/
The curious thing is that the css selector works, i can test it by setting the border for example. But the same method doesn't work when i set the opacity. What am i doing wrong here?
rules in the style attribute have higher precedence than rules defined in author stylesheets. You can either use opacity: 0.5 !important (not the best idea) or define the other rules in the stylesheet as well.
http://jsfiddle.net/6uLTr/1/