Animation using CSS class - html

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>

Related

label doesn't display when hover

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>

Align all 4 items in HTML/CSS

I have my timer that has date/hour/minute/seconds and the only one that doesn't align is the seconds. I tried many things such as different ways to align. So how can I align all the timer's items.
Can someone help me?
HTML
<div class="jumbotron timer">
<h2>Time until the tracker is activated</h2>
<div class="timertxtc">
<div class="timertxt" id="daysBox"></div>
<h4>Days</h4>
</div>
<h3 class="space">1</h3>
<div class="timertxtc">
<div class="timertxt" id="hoursBox"></div>
<h4>Hours</h4>
</div>
<h3 class="space">1</h3>
<div class="timertxtc">
<div class="timertxt" id="minsBox"></div>
<h4>Minutes</h4>
</div>
<h3 class="space">1</h3>
<div class="timertxtc">
<div class="timertxt" id="secsBox"></div>
<h4>Seconds</h4>
</div>
<script>cdtd();</script>
</div>
CSS
body {
margin: 0;
padding: 0;
background-image: repeating-linear-gradient(
90deg,
#FFFFFF,
#FFFFFF 18px,
#CA1D20 0px,
#CA1D20 28px
);
}
h1{
font-size: 64px;
text-align: center;
color: #3498db;
text-shadow: 3px 3px 0px #000;
}
h2{
font-size: 32px;
text-align: center;
color: #3498db;
text-shadow: 3px 3px 0px #000;
margin: auto;
}
.jumbotron.timer{
width: 48%;
height: 360px;
margin: auto;
background-color: #669900;
}
.timertxt{
color: #3498db;
text-shadow: 3px 3px 0px #000;
font-size: 64px;
padding-left: 12px;
padding-right: 12px;
border: 2px solid #2980b9 ;
border-radius: 5px;
background-color: #2980b9;
text-align: center;
}
.space{
font-size: 12px;
display: inline-block;
float: left;
visibility: hidden;
}
.timertxtc{
width: 25%;
height: 120px;
float: left;
display: inline-block;
margin: auto;
}
h4{
font-size: 32px;
color: #3498db;
text-shadow: 3px 3px 0px #000;
display: inline-block;
text-align: center;
}
The character in your <h3 class="space">1</h3> elements was causing the content of the container div to exceed 100% pushing 'seconds' on to the next line.
See fixes in the following fiddle:
https://jsfiddle.net/oLncm9d2/4/
Instead of using an element for 'spacing' padding-right / padding-left in combination with box-sizing: border-box; can achieve the spacing you want, without disrupting width calculations. (The solution demonstrates this and has removed the <h3 class="space">1</h3> elements.)
Note: I increased the container width to prevent excessive overlap for demonstration.

Button with a bigger text centering issue

I´m trying to do some buttons with image and text, and I already did this work.
But now I´m studying a diferente hypothesis, If I have a text bigger I´m trying to center the text in the button but I´m not having sucess put this right. I´m not having succeess putting my very big is not good align-center just below the 1st text.
Have you ever had a case like this? How we can solve this?
I have this Html for two buttons:
<button class='btn'>
<img class="big_btn" src="icon1.png" width="40" height="40"/>
Big button so big <span> very big is not good</span>
</button>
<button class='btn'>
<img src="icon1.png" width="40" height="40">
2button big
</button>
And I have this css file:
.btn {
position: relative;
width: 180px;
height: 60px;
margin-top:7%;
padding: 0 10px 0 10px;
line-height: 37px;
text-align: left;
text-indent: 10px;
font-family: 'bariol_regularregular';
font-size: 15px;
color: #333;
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
background: #f1f1f1; /* button background */
border: 0;
border-bottom: 2px solid #999; /* newsletter button shadow */
border-radius: 14px;
cursor: pointer;
-webkit-box-shadow: inset 0 -2px #999;
box-shadow: inset 0 -2px #999;
}
.btn:active {
top: 1px;
outline: none;
-webkit-box-shadow: none;
box-shadow: none;
}
.btn img { float: left;}
.btn .big { margin-top:10px;}
.btn:hover { background-color: #f7f7f7;}
Here's the Fiddle: http://jsfiddle.net/3F9pu/
My image updated:
Your problem is your line-height attribute. If you set that to be 37px, each new line of text will be separated by 37px. Remove `line-height:37px and the text will wrap around the image.
line-height: 37px
I also removed your text-indent and replaced it with a margin on your floated image to make the text all align properly.
.btn img{
float:left;
margin-right: 10px;
}
text-indent: 10px
JSFiddle
Use a CSS background image.
Have a fiddle - Fiddle Link!
HTML
<button class='btn'>Big button so big very big is not good</button>
<button class='btn'>2button big</button>
CSS
.btn {
background: url("http://lorempixel.com/output/cats-q-c-40-40-3.jpg") #CCC 10px no-repeat;
border: none;
padding: 10px 10px 10px 60px;
width: 200px;
text-align: left;
vertical-align: top;
min-height: 60px;
cursor: pointer;
}
.btn:hover {
background-color: #F00;
}

position of website elements

I have an issue with rendering my website for IE, Chrome and Opera. In Firefox the positioning works well:
while in the other browsers it looks like crap:
I have tried several positioning and padding options, but no luck. The problems appeared as I replaced the drop down menu with a jQuery replacement to enhance it graphically. The original dropdown is still there but with the css-option "display: none". I'd be thankful for a hint!
Here is the css:
This is the big blue box
.searchHomeForm a, .searchHomeForm a:hover {
color:#000000;
}
A invisible box around the three elements
div.searchHomeForm , .searchform {
height: 37px;
margin-left: auto;
margin-right: auto;
}
The white search bar
.search_bar {
position: inherit;
height: 25px;
letter-spacing: 0.02em;
line-height: 25px;
padding: 9px 0 0px 9px;
width: 390px;
border: 1px solid #95B6D6;
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.11) inset;
border-radius: 0.25em 0 0 0.25em;
}
the jQuery Dropdown replacement
#searchformReplacement {
background: #EBEBEB;
padding: 0px 1px 5px 0;
margin-bottom: 3px;
border-top: 1px solid #95B6D6;
border-bottom: 1px solid #95B6D6;
width: 109px;
position: inherit;
}
the find button
.find_button {
background: url("../images/lupevufindsearchsubmit1.png") no-repeat scroll #bBbBbB;
-moz-border-radius: 0.25em;
border-radius: 0 0.25em 0.25em 0;
position: inherit;
height: 36px;
line-height: 36px;
margin: 0px 0 3px -1px;
padding: 4px 10px 4px 10px;
width: 60px;
border-top: 1px solid #95B6D6;
border-right: 1px solid #95B6D6;
border-bottom: 1px solid #95B6D6;
border-left: none;
box-shadow: 2px 2px 5px rgba(76, 133, 187, 0.50) inset;
transition: all 0.2s ease-in-out 0s;
}
Try removing position: inherit from the .search_bar {}, #searchformReplacement {}and .find_button {} add display:inline-block for each
or add display:inline and float:left for each. You may have to clear floats if you use float:left
maybe use float: left; on the three elemetns next to each other?
I made you a little example to have the required position, I'm using the inline-block propriety (and I love it) :
Html
<div id="container">
<input type="text" class="inline-block" />
<div class="inline-block">
Your custom select
</div>
<button type="submit" class="inline-block">Search</button>
</div>
CSS
.inline-block {
display:inline-block;
*display:inline; /*IE hack*/
*zoom:1; /*IE hack*/
}
#container {
background:lightBlue;
width:300px;
margin:0 auto;
text-align:center;
}
See the working fiddle !
Yes, clearing your floats are important as madhushankarox has pointed out. But you don't always need to use floats, especially not in your case. Plus here's an extra bonus if you ever need to place your form into a liquid layout page. It should proportion itself out equally on most screens that are wide or thin.
CSS
/*the blue rounded box*/
#bluebox {
padding:3% 5%;
margin:0 25%;
background:#d0dcea;
border:solid 1px #b7c2d2;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
}
.fieldset-search {
text-align:center;
}
/*The white search bar*/
.input-search {
padding:5px;
margin:0;
width:50%;
vertical-align: baseline;
border: solid 1px #b7c2d2;
background: #fff;
outline: 0;
}
/*the jQuery Dropdown replacement*/
.list-search {
padding:4px;
margin:0 0 0 -5px;
}
/*the find button*/
.submit-search {
padding:4px 10px;
margin:0 0 0 -5px;
}
HTML
<div id="bluebox">
<div class="fieldset-search">
<input type="text" name="search" class="input-search">
<select name="list" class="list-search"><option></option></select>
<button type="search" class="submit-search">Go</button>
</div>
</div>

Child elements :hover on Internet Explorer not working (HTML/CSS)

I built the following website basically from scratch, and it works perfectly on most browsers (Chrome, Firefox, Safari, Edge), but unsurprisingly not on IE (tested on 9,10,11): Alliance Française du Manitoba
The problem is with the dropdown menus. When hovering over one of the menu headers (<div class="headerMenuItem">), a mega-menu (<div class="headerMenuDropdown">) should appear. Currently, when hovering, the headerMenuItems are highlighting, as expected, but the child headerMenuDropdown isn't appearing.
/***Header Menu***/
#headerMenu { /*Menu Wrapper*/
float: left;
margin: 12px auto 0px;
padding: 0px;
}
.headerMenuItem { /* Individual menu item */
display: block;
float: left;
overflow: hidden;
border-radius: 5px 5px 0px 0px;
margin-top: 6px;
padding-bottom: 10px;
}
.headerMenuItem:hover {
background-color: #d4d9db;
text-decoration: none;
}
.headerMenuItem>a {
padding: 8px 12px 0px;
text-align: center;
border-radius: 5px 5px 0px 0px;
font-weight: bold;
color: #444;
}
.headerMenuItem a:hover { /* override default link behaviour */
text-decoration: none;
color: #444;
}
/*Menu expand*/
.headerMenuDropdown { /* mega-menu wrapper */
float: left;
display: none;
position: fixed;
background-color: white;
width: 100%;
left: 0;
top: 100%;
border-top: 1px solid #da002e;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 105;
text-align: center;
}
.headerMenuItem:hover .headerMenuDropdown { /*Display dropdown*/
display: block;
animation: headerDropdownAppear;
animation-duration: 0.4s;
}
#keyframes headerDropdownAppear {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
/* Create up to 6 equal columns that floats next to each other */
.row {
width: 1200px;
display: block;
margin-left: auto;
margin-right: auto;
}
.column {
float: left;
width: 15.53848%;
padding: 10px 10px 10px 0px;
}
.column span,
.column a {
float: none;
text-decoration: none;
display: block;
text-align: left;
padding: 1px;
}
.column>span {
font-weight: bold;
}
.column>span>span {
padding-left: 15px;
text-indent: -10px;
font-weight: lighter;
font-size: 0.8em;
}
.column>span>span>a {
padding-left: 15px;
margin-left: -15px;
padding-bottom: 3px;
line-height: 120%;
}
.column a:hover {
background-color: #d4d9db;
}
<div id="headerBottom">
<nav id="headerMenu">
<div class="headerMenuItem">
Learn French
<div class="headerMenuDropdown">
<div class="row">
<div class="column">
<span>
Column 1
<span>
Link 1
</span>
<span>
Link 2
</span>
...
</span>
</div>
<div class="column">
<span>
Column 2
...
</span>
</div>
...
</div>
</div>
</div>
<div class="headerMenuItem">
Tests & Exams
<div class="headerMenuDropdown">
<div class="row">
...
</div>
</div>
</div>
...
</nav>
...
</div>
I assumed that this had to do with one of two known IE bugs:
:hover inconsistencies
Unsuported > selector
However, both of these should have been phased out as issues by IE 9, but I'm having issues on IE 11! I've got a proper <!DOCTYPE html>, HTML5Shiv, and even crossover.htc, but nothing seems to work.
This leads me to think that the issue is with the CSS selector
.headerMenuItem:hover .headerMenuDropdown
EDIT: However, IE Inspector shows that it's behaivng properly!
Any known fixes?