label doesn't display when hover - html

hi I want the label "hidden-btn-txt" display when hover
but It doesnt show at all when the mouse is on the label
i tried to do hover to the "hidden-btn" but it doesnt work
html in tsx:
return (<ul className='tickets'>*
{filteredTickets.map((ticket) => (<li key={ticket.id} className='ticket'>
<div className="hidden-btn" onClick={this.onHide.bind(this, ticket.id)} >
<label id="hidden-btn-txt">Hide</label>
</div>
<h5 className='title'>{ticket.title}</h5>
<p className='content'>{ticket.content}</p>
<footer>
<div className='meta-data'> <span> By {ticket.userEmail} | { new Date(ticket.creationTime).toLocaleString()}</span>
{ticket.labels ? this.renderLabels(ticket.labels): null}
</div>
</footer>
</li>))}
</ul>);
css:
.ticket {
width: 100%;
flex-shrink: 0;
border-radius: 8px;
background-color: #fff;
box-shadow: 0 2px 6px 1px #e1e5e8;
margin-bottom: 14px;
display: flex;
flex-direction: column;
border: 1px solid #fff;
padding: 10px 20px;
transition: box-shadow .2s ease-in-out;
position: relative;
&:hover {
box-shadow: 0 2px 6px 1px #d3d7da;
}
#hidden-btn-txt{
display: inline-block;
color: #20455e;
font-size: 12px;
font-style: normal;
text-align: right;
float: right;
}
#hidden-btn-txt.hover{
display: inline-block;
}

Using something like this should help your casue:
onHover = () => {
//Apply your classes here.
}
<label id="hidden-btn-txt" onMouseOver={this.onHover}>Hide</label>

Related

CSS element automatically closing when active / selected

I have a searchbar, which is initially hidden until the user "hovers" over the div "searchbar". The issue I had was if the user did not stay hovered over the searchbar, it would then close and be hidden again. I wanted to change this to :active, meaning the user has to click to show and hide ... however, when changing the CSS to :active, the searchbar opens and instantly closes on itself. Also if I press once and hold down the mouse, it stays open...
Any suggestions where I am going wrong?
https://codepen.io/richag_ff/pen/bGayzeP
<div class="searchbar">
#Html.TextBox("SearchText", ViewBag.SearchText as String, new { #class = "search_input", placeholder = "Search by part or reference" })
<i class="fa fa-search search_icon_i"></i>
</div>
.searchbar{
margin-bottom: auto;
margin-top: auto;
height: 60px;
border-radius: 30px;
padding: 10px;
display: flex;
}
.search_input{
color: #858585;
border: 0;
outline: 0;
background: none;
width: 0;
caret-color:transparent;
line-height: 40px;
transition: width 0.4s linear;
}
.searchbar:hover > .search_input{
padding: 0 10px;
width: 215px;
caret-color:#000;
transition: width 0.4s linear;
}
.searchbar:hover > .search_icon{
background: white;
color: #000;
}
.search_icon{
height: 40px;
width: 40px;
float: right;
display: flex;
justify-content: center;
align-items: center;
border-radius: 50%;
color:#858585;
text-decoration:none;
}
Update
OP also needs the input to stay in the "open" state after it has been clicked and returned back to the "closed" state when clicked again. There were changes to the markup:
Add a hidden checkbox
.searchbar is a <label>
.search-icon is a <b> because an interactive tag like <a> will usually result in unexpected behavior when it is in another interactive tag (like <label>).
The toggling feature is possible by leveraging the checkbox/radio button association with <label>:
Figure I
// checkbox is display: none
<input id='switch' type='checkbox'>
// ⇳ id and for must match
<label for='switch' class='searchbar'>
<input id='search' type='search'><b
...
</label>
when a chk/rad input is associated to a <label> -- whenever one is clicked by the user, the other is also clicked remotely. In oder to enable an association, the chk/rad must have an id and the <label> must have a [for] attribute with the chk/rad id (see figure I).
When the <label> is clicked so is the checkbox which in turn changes it's state to :checked. Once checked, it can change all tags that proceed it by the use of adjacent sibling combinator, general sibling combinators, and descendant combinators. Unfortunately, it's not perfect -- because the <label> is not clickable where the input#search resides. Only the areas to the left and right of #search is clickable. I made some outlines to popup whenever the <label> is clicked to indicate to the user that it's in a "locked" state.
:active state only happens when the user keeps the mouse button down. Use :focus on the input. The user clicks the input once and it's in the full length state until the user clicks elsewhere. The .search-icon can be controlled as well be using the adjacent sibling combinator:
Figure II
#search:focus + .search-icon {...
/* If input is focused by user then if the next tag has class
.search-icon, apply the styles on .search-icon */
html {
font: 2ch/1.25 'Segoe UI'
}
.searchbar {
display: flex;
justify-content: center;
align-items: center;
margin: 50px auto;
padding: 0;
line-height: 40px;
border: 4px groove lightgrey;
border-radius: 5px;
cursor: pointer;
}
#search {
display: inline-block;
font: inherit;
width: 0;
border: 0;
outline: 0;
background: none;
caret-color: transparent;
height: 40px;
transition: width 0.4s linear;
}
.searchbar:hover #search,
#search:focus,
#switch:checked+.searchbar #search {
width: 75%;
margin: 0 12px;
padding: 2px 4px;
border: 3px inset rgba(129, 129, 129, 0.3);
border-radius: 5px;
caret-color: #000;
}
#switch:checked+.searchbar #search {
outline: 3px navy solid;
}
#switch:checked+.searchbar {
background: #ddd;
}
.search-icon {
display: flex;
justify-content: center;
align-items: center;
margin-left: -5%;
color: #858585;
text-decoration: none;
cursor: pointer;
}
.searchbar:hover .search-icon,
#search:focus+.search-icon,
#switch:checked+.searchbar .search-icon {
margin-left: 0;
padding: 5px;
border: 2px groove grey;
border-radius: 50%;
transition: border 0.3s linear;
}
#switch:checked+.searchbar .search-icon {
outline: 3px navy solid;
color: navy;
}
.fa-lg {
display: inline-block;
padding: 10px 2.5px;
}
#switch {
display: none;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" rel="stylesheet">
<input id='switch' type='checkbox'>
<label for='switch' class="searchbar">
<input id='search' name='search' type='search'>
<b class="search-icon"><i class="fa fa-search fa-lg"></i></b>
</label>
You need to use :focus for this. But to get focus to work on a div you need to add tabindex="-1" to the div.
Because focus only works for 1 element. You can't focus on the input. Therefor we have to add a jQuery solution to fix it.
See snippet below! ✌️
$('#TmInM').on('focus', function () {
$('#TmInM').addClass('focus');
$('#search').focus();
}).on('blur', function (e) {
$('#TmInM').removeClass('focus');
$('#search').blur();
});
$('#search').on('focus', function () {
$('#TmInM').addClass('focus');
$('#search').focus();
}).on('blur', function (e) {
$('#TmInM').removeClass('focus');
$('#search').blur();
});
#TmInM {
width:40vw;
height:3.4vh;
background: #FFF;
display: inline-block;
margin-left:10vw;
margin-top:0.9vh;
color:#777;
border:2px solid transparent;
outline:none;
border-radius:4px;
-webkit-box-shadow:0px 0px 1px 1px #BBB;
-moz-box-shadow:0px 0px 1px 1px #BBB;
box-shadow:0px 0px 1px 1px #BBB;
}
#TmInM.focus {
border:2px solid #00b646;
outline:none;
}
#TmInM img {
float: left;
margin-top:0.4vh;
margin-left:0.4vw;
opacity: 0.2;
}
#TmInM input {
width:30vw;
height:1.8vh;
padding:0.2vw;
margin-top:0.2vh;
margin-left:0.2vw;
font-size:0.8vw;
border:0;
}
#TmInM input::placeholder {
color:#CCC;
font-style:italic;
}
#TmInM input:focus {
border:2px solid transparent;
outline:none;
-webkit-box-shadow:0px 0px 1px 1px #FFF;
-moz-box-shadow:0px 0px 1px 1px #FFF;
box-shadow:0px 0px 1px 1px #FFF;
}
#TmInM input:focus::placeholder {
color:#999;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="TmInM" tabindex="-1">
<img src="<?php echo $baseURL; ?>images/search.png" alt="" /><input type="text" name="search" id="search" class="inputmain" placeholder="Send out a leprechaun to go search what u are looking for..." value="" />
</div>

Animation using CSS class

I have an HTML component which looks like this.
When I add a conditional class to this component two "div"s at the bottom should change its position to the right side of "Primart EMF" text, which looks like this.
I am able to achieve it using display property by changing it from block to inline-block. But this transition is not smooth. I want to add some animation to it, but transition doesn't work on display property.
Can someone please guide me on how to achieve this?
HTML
<ul class="condition-list edit--mode--off"> <!-- edit--mode--off is a dynamic class-->
<li class="condition-element condition-element-selected">
<div class="condition-element-type">Primary EMF</div>
<div class="condition-element-names">
<div class="condition-element-name condition-growth">Innovation</div>
<div class="condition-element-name condition-achievement">Mastery</div>
</div>
</li>
</ul>
CSS
.condition-element-type {
display: inline-block;
max-width: 71px;
margin: 2px 10px 0 0;
}
.condition-element-names {
display: inline-block;
}
.condition-element-name {
display: inline-block;
margin-left: 10px;
border-radius: 8px;
color: $color-white;
font-size: 11px;
margin: 0 8px 8px 0;
height: calc(1em + 5px);
padding: 4px 8px 2px 8px;
margin: -3px 8px 8px 0;
}
.edit--mode--off .condition-element-names {
display: block !important;
margin-top: 5px;
}
Not sure if this is doable as I see only a part of your code, but it is usually more convenient to use transform and transition for smooth transitions. Hope below example helps (click red-bordered buttons to see the transition animation):
document.querySelector('.condition-list').addEventListener('click', function(){this.classList.toggle('edit--mode--off')});
.condition-element-type {
display: inline-block;
max-width: 71px;
margin: 2px 10px 0 0;
}
.condition-element-names {
display: inline-block;
transition: transform .4s ease-out;
}
.condition-element-name {
display: inline-block;
margin-left: 10px;
border-radius: 8px;
color: $color-white;
font-size: 11px;
margin: 0 8px 8px 0;
height: calc(1em + 5px);
padding: 4px 8px 2px 8px;
margin: -3px 8px 8px 0;
border: 1px solid red;
cursor: pointer;
}
.edit--mode--off .condition-element-names {
transform: translate(-100px, 40px);
margin-top: 5px;
}
<ul class="condition-list edit--mode--off">
<!-- edit--mode--off is a dynamic class-->
<li class="condition-element condition-element-selected ">
<div class="condition-element-type">Primary EMF</div>
<div class="condition-element-names">
<div class="condition-element-name condition-growth">Innovation</div>
<div class="condition-element-name condition-achievement">Mastery</div>
</div>
</li>
</ul>

Targeting span within button tag on hover: How to change border color and pointer?

I have some cards and want to change the properties border-color and pointer-events when a user hovers a span tag which is inside a button tag.
This is no problem if i use a tag, see First Card on the left:
https://codepen.io/anon/pen/JzzEvj
However, when using a PRG pattern with form and button changing the pointer event and the border-bottom color when hovering does not work with Firefox. (See Second Card on the right side)
Any ideas how to fix this in Firefox?
Desired outcome see Card on the left:
The cursor should have pointer state when hovering the image
The cursor should have pointer state when hovering the card heading
The card heading's border-bottom color should change color when hovering the card heading
I spend a lot of time on this issue but only found this solution https://codepen.io/anon/pen/PLLWxJ which is not exactly the same, because
the card heading's border-bottom color changes when hovering any part of the card.
all parts of the card look clickable when hovering. The cursor state should only change to pointer when hovering the image or the card heading.
a {
text-decoration: none;
}
.product-cards-wrapper {
background: #fff;
padding: 64px 0;
}
.product-cards {
display: flex;
justify-content: center;
flex-wrap: wrap;
}
.product-card {
border: 1px dotted #ccc;
cursor: default;
margin: 0 16px 32px;
width: 250px;
text-align: center;
}
.product-card-img-wrapper {
align-items: center;
cursor: pointer;
display: flex;
justify-content: center;
height: 150px;
line-height: 0;
margin-bottom: 16px;
}
.product-card-heading {
border-bottom: 1px solid #e5e5e5;
color: #2bb3f0;
display: inline;
font-family: sans-serif;
font-size: 18px;
font-weight: 700;
line-height: 1.6;
text-align: center;
transition: border-color .2s;
}
.product-card-heading:hover {
border-color: #2bb3f0;
cursor: pointer;
}
.product-card-label {
background: #fee5ad;
border-radius: 99px;
color: rgba(0, 0, 0, .54);
cursor: text;
font-family: sans-serif;
font-size: 14px;
font-weight: 600;
margin-top: 4px;
padding: 2px 10px;
}
.product-card>button {
background: 0;
border: 0;
padding: 0;
width: 100%;
}
.product-card-heading {
border-bottom: 1px solid #e5e5e5;
color: #2bb3f0;
cursor: pointer;
transition: border-color .2s;
}
.product-card button .product-card-img-wrapper,
.product-card button .product-card-heading {
cursor: pointer;
}
.product-card button .product-card-heading:hover {
border-color: #2bb3f0;
}
.product-card-labels {
display: block;
font-family: sans-serif;
}
<section class=product-cards-wrapper>
<div class=product-cards>
<a class=product-card href=#>
<div class=product-card-img-wrapper>
<img src=https://via.placeholder.com/160x150 alt="">
</div>
<div class=product-card-heading>First Card</div>
<div class=product-card-labels><span class=product-card-label>Label</span></div>
</a>
<form class=product-card action=# method=post target=_blank>
<button name=l value=123>
<span class=product-card-img-wrapper>
<img src=https://via.placeholder.com/120x150 alt="">
</span>
<span class=product-card-heading>Second Card</span>
<span class=product-card-labels><span class=product-card-label>Label</span></span>
</button>
</form>
</div>
</section>
This was a six years old Firefox bug which was fixed in Firefox 66.
Children of the button tag now do respond to :hover. :)

how can I align the button and the text inline

I want to align the button and the text in the same line.
<div class="oferts">
<div class="container" style="line-height: 300px; text-align: center;">
<h1>Bucura-te de ofertele noastre alaturi de familia ta <button class="oferts-button">Vezi toate beneficiile terapiilor</button>
</div>
</div>
button {
background: transparent;
color: #666;
border: 1px solid #d4d4d4;
padding: 10px 20px;
margin: 0 10px 0 10px;
transition: border .3s ease-in;
}
button:hover {
border: 1px solid #909090;
padding: 10px 20px 10px 20px;
}
button a {
font-family: 'Raleway', sans-serif;
color: #666;
font-size: 14px;
}
.oferts-button a {
font-family: 'Raleway', sans-serif;
color: #fff;
}
.oferts-button:hover {
border: 1px solid #fff;
}
.oferts {
width: 100%;
display: table;
height: 300px;
background:url(../img/back.jpg) center no-repeat;
}
You can use the vertical-align css property on both elements:
container {
line-height: 300px;
text-align: center;
}
container > h1,
container > h1 a {
vertical-align: middle;
}
DEMO
HTML Removed h1 tags, as was not ending and didn't even found in css
NOTE: Used font-size - 32px because h1 tag = 32px
<div class="oferts">
<div class="container">
Bucura-te de ofertele noastre alaturi de familia ta
<button class="oferts-button">
Vezi toate beneficiile terapiilor
</button>
</div>
</div>
CSS Add this class to your CSS
.container
{
line-height: 300px;
text-align: center;
font-weight:bold;
font-size:32px;
}

Hide/show text in body on hover of child element

I'd like to initially hide text in my body, but show it once an element in a child div is hovered over. So In this case, I want them both to initially start out as display: none but then when I hover over the letter "H" I want "Text A" to show. When I hover over letter "E" I want "Text B" to show. I don't want to put my #content elements inside of my #word elements. I want to keep them as separate divs.
Any Ideas?
(See Fiddle below)
HTML:
<div id="word">
<h1><a id="h" class= "letter" href=#>H</a></h1>
<h1><a id="e" class= "letter" href=#>E</a></h1>
<h1><a id="l" class= "letter" href=#>L</a></h1>
<h1><a id="l2"class= "letter" href=#>L</a></h1>
<h1><a id="o" class= "letter" href=#>O</a></h1>
</div>
<div id="content">
<div id="textA">Text A</div>
<div id="textB">Text B</div>
</div>
CSS:
body {
font-family: 'Chango', cursive;
font-size: 115px;
color: white;
text-shadow: 5px 5px 5px #000;
width: 100%;
height: 100%;
margin: 0px;
background: black;
}
#name {
position:absolute;
height:100%;
width: 70%;
display: table;
padding: 0 15% 0 15%;
background: black;
}
h1 {
display: table-cell;
vertical-align: middle;
text-align:center;
height: 1em;
}
a {
/*border: 1px solid black;*/
display: inline-block;
line-height: 89%;
overflow: hidden;
}
a:visited, a:active {
text-decoration: none;
color: white;
/*color: #E8E8E8;*/
}
a:link {
text-decoration: none;
color: white;
text-shadow: 3px -3px 0px black, -2px 2px 5px #0056b2;
}
a:hover {
text-shadow: 5px 5px 5px #000;
color: white;
}
Fiddle: http://jsfiddle.net/ADfhj/1/
PS- I've tried the following CSS to no avail:
#textA {
display: none;
}
#word:hover #textA {
display: block;
}
There is no way achieving it using css only. However you can try simple javascript/jquery.
$('.letter').mouseover(function(){
var cont = $(this).attr('id');
$('#content>div').hide();
$('#text_'+cont).fadeIn();
});
Check the Fiddle