Nested input and select box with hover transition - css

I have a select box that sits directly next to an input box, (see relevant snippet below).
Currently, two seperate transition animations play in order to display both boxes on hover.
I would like to only use a single transition to display both boxes on hover.
Is there a cleaner way to do this? Could different positioning properties help me? Thanks in advance!
html, body {
background-color: rgba(64, 124, 165, 1);
}
.quick-search-container {
cursor: pointer;
width: 350px;
vertical-align: top;
white-space: nowrap;
position: relative;
top: -5px;
float: left;
}
.quick-search-container input#search {
width: 20px;
height: 30px;
background: rgba(64, 124, 165, 1); /*replacement*/
border: none;
font-size: 10pt;
float: right;
color: #262626;
padding-right: 35px;
padding-left: 5px;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
color: #000;
-webkit-transition: width .55s ease, background-color .55s ease;
-moz-transition: width .55s ease, background-color .55s ease;
-ms-transition: width .55s ease, background-color .55s ease;
-o-transition: width .55s ease, background-color .55s ease;
transition: width .55s ease, background-color .55s ease;
}
.quick-search-container input#search {
color: #65737e;
border: none;
}
.quick-search-container .icon {
position: absolute;
vertical-align: text-top;
right: 0;
margin-right: 10px;
margin-top: 6px;
color: #333;
font-size: 18px;
}
.quick-search-container .selector {
float: right;
vertical-align: text-top;
margin-right: 10px;
margin-top: 6px;
color: #ffffff;
font-size: 18px;
}
.quick-search-container input#search:focus,
.quick-search-container input#search:active,
select#selector:active {
outline: none;
}
.quick-search-container:hover input#search {
outline: none;
width: 180px;
background: #fff;
}
.quick-search-container:hover select#selector {
outline: none;
width: 100px;
}
.quick-search-container:hover .icon {
color: rgba(64, 124, 165, 1); /*replacement*/
}
.quick-search-container .selector {
margin-right: 0px;
margin-top: 0px;
transition: width .22s ease, background-color .55s ease;
}
.quick-search-selector {
margin-right: 0px;
margin-top: 0px;
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
border: none;
height: 30px;
width: 0px;
color: black;
transition: width .55s ease, background-color .55s ease;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<a class="quick-search-container">
<span class="icon">
<i (click)="initQuickSearch()" class="fa fa-search"></i>
</span>
<input type="search" id="search" placeholder="Search...">
<span class="selector">
<select class="quick-search-selector" id="selector">
<option>VIN</option>
<option>Make</option>
<option>Model</option>
<option>Cow</option>
</select>
</span>
</a>

Just wrap input and select boxes into a container and set animations on it, see the simplified demo by using flexbox below. You can adjust the style as needed.
jsFiddle
html {
background-color: rgba(64, 124, 165, 1);
}
.quick-search-container {
position: relative;
width: 250px;
display: flex;
justify-content: flex-end;
align-items: center;
border: 1px solid;
}
.input-select {
width: 0;
overflow: hidden;
transition: width 1s;
display: flex;
}
.quick-search-selector {
width: 30%;
height: 30px;
}
.quick-search-input {
width: 70%;
-webkit-appearance: none;
outline: 0;
height: 30px;
}
.quick-search-container:hover .input-select {
width: 100%;
}
.quick-search-button {
position: absolute;
right: 0;
top: 0;
bottom: 0;
font-size: 16px;
background: none;
border: 0;
outline: 0;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<a class="quick-search-container">
<span class="input-select">
<select class="quick-search-selector" id="selector">
<option>VIN</option>
<option>Make</option>
<option>Model</option>
<option>Cow</option>
</select>
<input type="search" class="quick-search-input" placeholder="Search..." id="search">
</span>
<button class="quick-search-button">
<i class="fa fa-search"></i>
</button>
</a>

Related

Rails 5: check box tag showing up two times

I use custom check box styling for my application, the problem I'm currently facing is that the custom check box style is rendered and the normal bootstrap check box.
As you can guess the custom check box is not clickable, but showing up.
Here is an example for the html:
<div class="form-group">
<strong class="container_check version_2">Ebay Angebot?
<%= check_box_tag :ebay_offer, true, [] %>
<span class="checkmark"></span>
</strong>
</div>
This is what the console throws out:
<input type="checkbox" name="ebay_offer" id="ebay_offer" value="true" checked="checked">
The corresponding bootstrap class (not my custom checkmark):
input[type=checkbox], input[type=radio]
My custom checkmark class
/** CHECKMARKS */
.container_check {
display: block;
position: relative;
font-size: 14px;
font-size: 0.875rem;
padding-left: 30px;
line-height: 1.3;
margin-bottom: 10px;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none
}
.container_check input {
position: absolute;
opacity: 0;
cursor: pointer
}
.container_check input:checked~.checkmark {
background-color: #2FE7B1;
border: 1px solid transparent
}
.container_check .checkmark {
position: absolute;
top: 0;
left: 0;
height: 20px;
width: 20px;
border: 1px solid #d2d8dd;
background-color: #fff;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
-ms-border-radius: 3px;
border-radius: 3px;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-webkit-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out
}
.container_check .checkmark:after {
content: "";
position: absolute;
display: none;
left: 7px;
top: 3px;
width: 5px;
height: 10px;
border: solid white;
border-width: 0 2px 2px 0;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg)
}
.container_check.version_2 {
padding: 6px 0 0 45px;
min-height: 30px
}
.container_check.version_2 .checkmark {
height: 30px;
width: 30px
}
.container_check.version_2 .checkmark:after {
left: 12px;
top: 8px;
width: 5px;
height: 10px
}
.container_check input:checked~.checkmark:after {
display: block
}
Quite often with this kind of thing the span needs to be within the field or within the label. You could try formats like these:
<%= check_box_tag :ebay_offer, true, [] do %>
<span class="checkmark"></span>
<% end %>
or
<%= label_tag :ebay_offer do %>
<%= check_box_tag :ebay_offer %>
Any desired label text <span class="checkmark"></span>
<% end %>

Maintain button hover effect when outside of button

Hovering over btn should trigger display: block; on btn2 (which it does), then maintain this hover effect when I move the mouse below and outside of btn until I am able to click btn2 (which it currently doesn't).
I thought I could do this by using margin on btn, but that didn't work.
body {
background-color: #673ab7;
font-size: 30px;
}
.btn {
margin-bottom: 50px;
text-align: center;
line-height: 100px;
position: absolute;
left: 50%;
width: 100px;
height: 100px;
background-color: #00bcd4;
border-radius: 100%;
transition: all .2s ease-in-out;
&:hover {
transform:scale(1.05,1.05)
}
}
.btn2 {
position: absolute;
top: 110px;
left: 50.5%;
text-align: center;
line-height: 55px;
border-radius: 50px;
display: none;
width: 50px;
height: 50px;
background-color: black;
transition: all .2s ease-in-out;
&:hover {
transform:scale(1.05,1.05)
}
}
.btn:hover +.btn2{
transition: all .2s ease-in-out;
display: block;
position: absolute;
transform: scale(1.05,1.05);
transform: translate(20px);
}
.icon {
color: white;
}
.icon2 {
color: white;
width: 26px;
line-height: 20px;
}
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<div class="container">
<i class="icon fa fa-link"></i>
<i class="icon2 fa fa-edit"></i>
</div>
Set your :hover css to the parent .container tag of both items so the hover rules are maintained when moving from one element to the next. This way you are maintaining the hover state when moving from child to child.
I also changed display:none; to visibility:hidden; and opacity:0|opacity:1 respectively. `display:none' isn't going to animate.
The animation time also allows for a short period of overlap (non :focus) when moving from one element to the other. With some keyframing you can make the move from one to the other a bit cleaner.
body {
background-color: #673ab7;
font-size: 30px;
}
.btn {
margin-bottom: 50px;
text-align: center;
line-height: 100px;
position: absolute;
left: 50%;
width: 100px;
height: 100px;
background-color: #00bcd4;
border-radius: 100%;
transition: all .2s ease-in-out;
&:hover {
transform:scale(1.05,1.05)
}
}
.btn2 {
position: absolute;
top: 110px;
left: 50.5%;
text-align: center;
line-height: 55px;
border-radius: 50px;
visibility:hidden;
opacity:0;
width: 50px;
height: 50px;
background-color: black;
transition: all .2s ease-in-out;
&:hover {
transform:scale(1.05,1.05)
}
}
.container:hover .btn +.btn2{
transition: all .2s ease-in-out;
visibility:visible;
opacity:1;
position: absolute;
transform: scale(1.05,1.05);
transform: translate(20px);
}
.icon {
color: white;
}
.icon2 {
color: white;
width: 26px;
line-height: 20px;
}
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<div class="container">
<i class="icon fa fa-link"></i>
<i class="icon2 fa fa-edit"></i>
</div>

Placeholder position when input has text

How to do placeholder styling when Input Text are focus, the placeholder are still visible and the font-size become smaller. For example like this:
I only need webkit support. Does webkit support such thing?
.input {
width: 200px;
height: 35px;
outline:0;
padding:0 10px;
}
.label { position: absolute;
pointer-events: none;
left: 20px;
top: 18px;
transition: 0.2s ease all;
}
input:focus ~ .label,
input:not(:focus):valid ~ .label{
top: 10px;
bottom: 5px;
left: 20px;
font-size: 12px;
}
<div>
<input type="text" class="input" required/>
<span class="label">Company Name</span>
</div>
You need to use a label element and modify it accordingly. Try this:
function fillClass() {
if ($(this).val() != '')
$(this).parent().addClass('input--filled');
else
$(this).parent().removeClass('input--filled');
}
$(".sign-in-input").focusout(fillClass);
.sign-in-input-ctr {
width: 100%;
display: inline-block;
vertical-align: top;
margin-bottom: 25px;
position: relative;
margin-top: 50px;
}
.sign-in-input {
width: 100%;
border: 2px solid transparent;
-webkit-transition: all 0.3s;
transition: all 0.3s;
height: 38px;
background-color: #fff;
outline: none;
border: 1px solid rgba(73, 73, 73, 0.2);
border-radius: 2px;
padding-left: 10px;
}
.sign-in-input:focus,
.input--filled .sign-in-input {
background-color: transparent;
border: 1px solid #a09e9e;
}
.sign-in-label {
width: 100%;
font-size: 12px;
position: absolute;
top: -18px;
pointer-events: none;
overflow: hidden;
padding: 0 15px;
left: 0;
-webkit-transform: translate3d(0, 30px, 0);
transform: translate3d(0, 30px, 0);
-webkit-transition: -webkit-transform 0.3s;
transition: transform 0.3s;
}
.sign-in-input:focus+.sign-in-label,
.input--filled .sign-in-label {
-webkit-transform: translate3d(-15px, 0, 0);
transform: translate3d(-15px, 0, 0);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="sign-in-input-ctr">
<input class="sign-in-input" type="text" name="email">
<label class="sign-in-label" for="signin-email"><span class="input-label-content">Email</span>
</label>
</div>
//------ contact us dropdown list
$(document).ready(function(){
$( ".form-group .form-control" ).focus(function() {
$(this).parent().addClass('inputFous');
}).blur(function() {
if($.trim($(this).val()) == '')
{
$(this).parent().removeClass('inputFous');
}
});
});
I think there is no webkit support for this, please check this code which will help you:- Jsfiddle

CSS: Transition effect on text input border

How to create transition effect like:
http://jsfiddle.net/mfn5nefb/6/
but for text input?
I tried replace h1 with input but it does not work.
You have to change the HTML structure to do the same with input because you can't use pseudo elements like :after on an input element (which is an auto closing element)
HTML
<div id="input">
<input type="text" value="CSS IS AWESOME" /><span></span>
</div>
CSS
#input {
color: #666;
position: relative;
display: inline-block;
}
span {
position: absolute;
left: 50%;
content: '';
height: 40px;
height: 5px;
background: #f00;
transition: all 0.5s linear;
width: 0;
bottom: -5px;
}
input:hover ~ span {
width: 200px;
margin-left: -105px;
}
See this fiddle
.input_container{
display: inline-block;
text-align: center;
}
.awsome_input{
padding: 5px 10px;
border: none;
background: transparent;
display: block;
}
.awsome_input_border{
display:inline-block;
width:0px;
height: 2px;
background: #FEC938;
position: relative;
top:-5px;
-webkit-transition: all ease-in-out .15s;
-o-transition: all ease-in-out .15s;
transition: all ease-in-out .15s;
}
.awsome_input:hover,
.awsome_input:active,
.awsome_input:focus{
outline: none;
}
.awsome_input:hover+.awsome_input_border,
.awsome_input:active+.awsome_input_border,
.awsome_input:focus+.awsome_input_border{
width:100%;
}
<div class="input_container">
<input type="text" class="awsome_input"
placeholder="What do you think?"/>
<span class="awsome_input_border"/>
</div>

Scrollable / hoverable CSS tooltip with psuedo elements

I have a hoverable CSS-only tooltip that works well in most instances, but I want to add a scrollbar when it exceeds a max-height. If I add max-height: 50px; overflow-y: auto, my pseudo elements :before and :after will disappear due to the overflow property.
See: http://jsfiddle.net/accelerate/24xwru1n/
Is there a way to add a scrollbar to my tooltip while maintaining my pseudo elements? Or will I have to live without my pseudo elements to make it work?
I'm afraid you have to add a wrapper when you want a scroll in hover and apply to this the css as in tooltip-text:
HTML
<div class="tooltip tooltip-scroll">Hover over me for scrollbar
<div class="wrapper">
<span class="tooltip-text">Hello there<br/>abc<br/>def<br/>ghi<br/>jkl<br/></span>
</div>
</div>
.wrapper{
position:relative;
}
.tooltip {
transform: none;
margin: 50px;
}
.tooltip:hover > .tooltip-text, .tooltip:hover > .wrapper {
pointer-events: auto;
opacity: 1.0;
}
.tooltip > .tooltip-text, .tooltip >.wrapper {
display: block;
position: absolute;
z-index: 6000;
overflow: visible;
padding: 5px 8px;
margin-top: 10px;
line-height: 16px;
border-radius: 4px;
text-align: left;
color: #fff;
background: #000;
pointer-events: none;
opacity: 0.0;
-o-transition: all 0.3s ease-out;
-ms-transition: all 0.3s ease-out;
-moz-transition: all 0.3s ease-out;
-webkit-transition: all 0.3s ease-out;
transition: all 0.3s ease-out;
}
/* Arrow */
.tooltip > .tooltip-text:before, .tooltip > .wrapper:before {
display: inline;
top: -5px;
content: "";
position: absolute;
border: solid;
border-color: rgba(0, 0, 0, 1) transparent;
border-width: 0 .5em .5em .5em;
z-index: 6000;
left: 20px;
}
/* Invisible area so you can hover over tooltip */
.tooltip > .tooltip-text:after, .tooltip > .wrapper:after {
top: -20px;
content: " ";
display: block;
height: 20px;
position: absolute;
width: 60px;
left: 20px;
}
.wrapper > .tooltip-text {
overflow-y: auto;
max-height: 40px;
display: block;
}
<div class="tooltip">Hover over me for no scrollbar<span class="tooltip-text">Hello there<p/>abc<br/>def<br/>ghi<br/>jkl<br/></span></div>
<p/><p/><p/>
<div class="tooltip tooltip-scroll">Hover over me for scrollbar
<div class="wrapper">
<span class="tooltip-text">Hello there<br/>abc<br/>def<br/>ghi<br/>jkl<br/></span>
</div>
</div>

Resources