I was trying to make this expandable search box expand to the left side, but it didn't work out. Can you guys please help me solving out this problem?
<div class="search-box d-flex justify-center align-center">
<input type="text" placeholder="Type to search ..">
<a class="p-20 cursor-pointer"><img class="search-btn max-h-20" src="./assets/logo/search.png" alt="search" /></a>
</div>
Here's the CSS :
.search-box:hover > input{
display: inline-block;
border-radius: 40px;
border: 1px solid whitesmoke;
padding: 0 10px;
width: 170px;
padding: 8px;
outline: none;
color: whitesmoke;
box-shadow: 0 0 5px whitesmoke, 0 0 10px whitesmoke;
}
.search-box:hover{
transition: width 0.6s ease;
}
Thanks!
i changed a your code a bit, but this is maybe like u want to (the red box with height and width is just for demonstration, feel free to delete that part ;) ):
.search-box {
display: flex;
justify-content: flex-end;
/* for demonstration */
background-color: red;
width: 250px;
height: 150px;
padding: 10px;
}
.search-box input {
border-radius: 40px;
border: 0;
box-shadow: 0 0 5px whitesmoke, 0 0 10px whitesmoke;
padding: 0;
width: 0;
height: 15px;
transition: padding 0.6s ease-in-out,
width 0.6s ease-in-out;
}
.search-box:hover > input{
display: inline-block;
border-radius: 40px;
width: 170px;
outline: none;
color: whitesmoke;
padding: 8px;
border: 1px solid whitesmoke;
}
<div class="search-box d-flex justify-center align-center">
<input type="text" placeholder="Type to search ..">
<a class="p-20 cursor-pointer"><img class="search-btn max-h-20" src="./assets/logo/search.png" alt="search" /></a>
</div>
Related
I want to make a search bar as this website's search bar: https://www.arrivalguides.com/en.
I tried with this code: (Here's a codepen)
HTML:
<div class="col-md-4 d-flex justify-content-end all-buttons">
<div class="col-md-4 d-flex justify-content-end search-bar">
<a nbButton outline class="text-decoration-none add-btn" id="add-btn-hide" >
<i class="nb-plus fa-1x"> </i> Add User
</a>
<button nbButton class=" multi-delete-btn" id="delete-btn-hide" >
<i class="nb-trash fa-2x"></i>
Delete All
</button>
<input type="text" class="search-input" id="search-input" fullWidth nbInput placeholder="Enter Search" (keyup)="onKey($event)" />
<button nbButton class="search-btn" nbTooltip="Quick Search " nbTooltipPlacement="top" status="primary">
<!-- <nb-icon icon="search-outline"></nb-icon> -->icon
</button>
</div>
</div>
CSS:
body{
margin:40px;
}
.all-buttons {
height: 30px;
padding-right: 0;
}
.info-btn {
padding: 0.4rem;
border-radius: 0.25rem;
margin-right: 3px;
background-color: blue;
border-color: blue;
}
.advanced-filters {
background-color: green;
padding: 0.6rem 0 0 0;
border-radius: 0.5rem;
margin-left: 1px;
}
.multi-delete-btn {
margin: 0 8px 0 3px;
color:white;
background-color: orange;
border-color:orange;
border-radius: 0.25rem ;
padding: 0 5px 0 0 ;
opacity: 1 !important;
transition: width 0.5s ease-out;
}
.add-btn {
border-color:blue ;
background-color: blue ;
color: white;
padding: 0.5rem;
border-radius: 0.25rem;
margin: 0 ;
opacity: 1 !important;
transition: width 0.5s ease-out;
}
.search-bar {
border: none !important;
margin-right: 2px !important;
border-radius: 100px ;
min-width: 33px !important;
position: relative;
transition: width 0.5s ease-out;
}
.search-input {
background: transparent;
border: 0;
background-color: lightblue;
opacity: 0;
width:40px !important;
transition: width 0.5s ease-out;
&:focus {
outline: 0;
}
}
.search-btn {
cursor: pointer;
border: 2px solid blue;
border-radius: 0.25rem !important;
background: transparent;
margin: 0 !important;
position: absolute ;
top:0 ;
bottom:0;
right: 0;
}
.search-bar:focus-within{
width:50% !important;
border: 2px solid brown !important;
.search-input{
width: 100% !important ;
background-color: rgba(196, 158, 233, 0.205);
color: black !important;
cursor: initial ;
opacity: 1;
}
.add-btn{
display: none !important;
}
.multi-delete-btn{
display: none!important;
}
}
The issue:
When I click outside of the search icon, the "Add" button and "Delete-all" button should appear. But in my case they are just moving. (When I click the search icon, the add-button and delete-all button disappear– this is okay)
Here is an approach isolating only the search input and a search input container. The input is absolutely positioned inside a relative container so that I could grow the input from right to left. I did this by anchoring it to the right side of the parent container using right: 0.
I'm combining focus-within and placeholder-shown to grow/shrink the input. Using placeholder-shown is needed to prevent the input from shrinking if the user has typed something in the input. To hide the placeholder text and only show the search icon when the input is shrunk, I'm making the placeholder text color transparent.
.search-input-container {
position: relative;
}
.search-input {
--search-icon-width: 24px;
--search-max-width-expanded: 20rem;
--search-max-width-collapsed: 2.3rem;
--search-color: #ccc;
background-color: var(--search-color);
max-width: var(--search-max-width-collapsed);
padding: .5rem 0.75rem;
overflow: hidden;
transition: 0.3s max-width, 0.3s margin;
border: none;
background-image: url(https://image.flaticon.com/icons/png/512/93/93642.png);
background-size: 18px;
background-repeat: no-repeat;
background-position: calc(100% - 10px) 50%;
position: absolute;
right: 0;
font-size: 16px;
border-radius: 15px;
}
.search-input:focus-within,
.search-input:not(:placeholder-shown) {
max-width: var(--search-max-width-expanded);
padding-right: var(--search-icon-width);
}
.search-input:not(:focus-within)::placeholder {
color: transparent;
}
/* Ignore */
body {
display: grid;
place-items: center;
}
<div class="search-input-container">
<input placeholder="search" type="search" class="search-input">
</div>
I get a space between my wrapper and the top of the page. I've tried a lot of fixes, but none that works.
The background image covers the background and is aligned to the top, but the wrapper, which has another background, seems to have a margin..
body {
height: 100vh;
background: url("https://i.imgur.com/HgflTDf.jpg") 50% fixed;
background-size: cover;
}
.wrap {
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
width: 100%;
min-height: 100%;
padding: 20px;
background: rgba(17, 71, 114, 0.85);
top: 0;
}
.login {
border-radius: 2px 2px 5px 5px;
padding: 10px 20px 20px 20px;
width: 90%;
max-width: 320px;
background: #ffffff;
position: relative;
padding-bottom: 80px;
}
input {
display: block;
padding: 15px 10px;
margin-bottom: 10px;
width: 100%;
border: 1px solid #ddd;
transition: border-width 0.2s ease;
border-radius: 2px;
}
input:focus {
outline: none;
color: #444;
border-color: 2196F3;
border-left-width: 35px;
}
.fa {
color: #fff;
font-size: 1em;
position: absolute;
margin-top: -47px;
opacity: 0;
left: 0;
transition: all 0.1s ease-in;
}
.fa:focus {
opacity: 1;
left: 30px;
transition: all 0.25s ease-out;
}
.tittel {
color: #444;
font-size: 1.2em;
font-weight: bold;
margin: 10px 0 30px 0;
border-bottom: 1px solid #eee;
padding-bottom: 20px;
}
.sub {
width: 100%;
height: 100%;
padding: 10px 10px;
background: #2196F3;
color: #444;
display: block;
border: none;
margin-top: 20px;
margin-bottom: 0px;
position: absolute;
left: 0;
bottom: 0;
max-height: 60px;
border: 0px solid rgba(0, 0, 0, 0.1);
border-radius: 0 0 2px 2px;
transform: rotateZ(0deg);
transition: all 0.1s ease-out;
border-bottom-width: 7px;
}
footer {
display: block;
padding-top: 50px;
text-align: center;
color: #fff;
font-weight: normal;
text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.2);
font-size: 0.8em;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
<div class="wrap">
<form action="" method="post" class="login needs-validation" novalidate>
<h4 class="tittel">Login</h4>
<input type="text" name="username" value="" placeholder="Username" required autofocus/>
<i class="fa fa-user"></i>
<input type="password" name="password" placeholder="Password" required>
<i class="fa fa-key"></i>
<input type="submit" class="sub" value="Login">
</form>
<footer>Company name</footer>
</div>
EDIT: The wrapper seems to be placed 30-40px below the top. The page can be scrolled down this exact length. Tried removing the padding in the .wrap, comment out the background for the body and played around in site inspector for Chrome, disabling and enabling css to see if any of it makes a difference, which it doesn't.
In most major browsers, the default margin is 8px on all sides. It is defined in pixels by the user-agent-stylesheet your browser provides.
Some browsers allow you to create and use your own user-agent-stylesheet, but if you are developing a website, I would recommend staying away from changing this, since your users most likely will not have a modified stylesheet and would then see a different page than you do.
If you want to change it, you can just do this:
body {
margin: 0;
padding: 0;
...
}
But if you have a large project and want to be more complete, use normalize.css. It resets a lot of default values to be consistent across browsers.
Credits to Jon Egeland
You have 20px padding in your wrap class, removing it will probably solve your issue -
Hope this is what you're looking for!
This works for me just fine, no padding needed:
.page-wrap {
max-width: 1200px;
display: flex;
flex-direction: column;
align-items: left;
overflow: hidden;
margin: 0 auto;
}
I have this problem on responsive I have this two text area
.row {
display: flex;
flex-wrap: wrap;
margin-right: -15px;
margin-left: -15px;
}
.col-md-12 {
flex: 0 0 100%;
max-width: 100%;
position: relative;
width: 100%;
padding-right: 15px;
padding-left: 15px;
}
.btn-group {
float: right;
display: inline-flex;
vertical-align: middle;
}
.form__group {
display: flex;
flex-direction: column-reverse;
}
.form__input {
height: 40px;
}
.horizontal-scroll {
white-space: nowrap;
overflow-x: auto;
}
.horizontal-scroll::-webkit-scrollbar {
-webkit-appearance: none;
width: 7px;
height: 4px;
border: 1px solid rgba(0,0,0,.3);
border-radius: 4px;
z-index: 9999;
}
.horizontal-scroll::-webkit-scrollbar-thumb {
z-index: 9999;
border-radius: 4px;
height: 2px;
width: 4px;
background-color: rgba(0,0,0,.5);
-webkit-box-shadow: 0 0 1px rgba(255,255,255,.5);
}
}
}
.disabled-custom {
resize: none;
overflow-y: hidden;
background: #e4ebf8;
border: none;
cursor: default;
}
.form__input {
border: 1px solid #ccd4e3;
border-radius: 4px;
width: 100%;
margin: 0;
margin-bottom: 2.4rem;
padding: 1rem;
padding-top: 1.1rem;
transition: all 0.3s ease;
display: block;
font-family: inherit;
}
.form__label {
font-size: 14px;
color: #324161;
display: table-header-group;
transition: all 0.3s ease;
display: inline-block;
margin-bottom: 4px;
}
<div class="row">
<div class="col-md-12">
<div class="btn-group">
<div class="form__group" style=" margin-right: 24px;">
<textarea wrap="off" class="form__input disabled-custom horizontal-scroll" style="min-width: 600px;" readonly>https://app.zeplin.io/project/5bb1fdc046eb4d20e8405978/screen/5c18f75217aa3f24677c39a8</textarea>
<label class="form__label">aijsdoaisjdoiajsoidjais</label>
</div>
<div class="form__group">
<textarea wrap="off" class="form__input disabled-custom horizontal-scroll" style="min-width: 120px;" readonly>30 Points</textarea>
<label for="test_passing_sc" class="form__label">Test Passing Scoreasdasjdajsn</label>
</div>
</div>
</div>
</div>
The left text area with label included it has width of 600px min and the right 120px I managed when text longer for the left text area I put a horizontal scroll but for the right side i need when the text its longer to be able to auto width on the left side and the left text area to decrease width.. Can someone help me with this..?
<!Doctype html>
<style>
.row {
display: flex;
}
.col-md-12 {
max-width: 100%;
position: relative;
width: 100%;
padding-right: 15px;
padding-left: 15px;
}
.btn-group {
display: inline-flex;
vertical-align: middle;
}
.form__group {
display: flex;
flex-direction: column-reverse;
}
.form__input {
height: 40px;
}
.horizontal-scroll {
white-space: nowrap;
overflow-x: auto;
}
.horizontal-scroll::-webkit-scrollbar {
-webkit-appearance: none;
width: 7px;
height: 4px;
border: 1px solid rgba(0, 0, 0, .3);
border-radius: 4px;
z-index: 9999;
}
.horizontal-scroll::-webkit-scrollbar-thumb {
z-index: 9999;
border-radius: 4px;
height: 2px;
width: 4px;
background-color: rgba(0, 0, 0, .5);
-webkit-box-shadow: 0 0 1px rgba(255, 255, 255, .5);
}
.disabled-custom {
resize: none;
overflow-y: hidden;
background: #e4ebf8;
border: none;
cursor: default;
}
.form__input {
border: 1px solid #ccd4e3;
border-radius: 4px;
width: 100%;
margin: 0;
margin-bottom: 2.4rem;
padding: 1rem;
padding-top: 1.1rem;
transition: all 0.3s ease;
display: block;
font-family: inherit;
}
.form__label {
font-size: 14px;
color: #324161;
display: table-header-group;
transition: all 0.3s ease;
display: inline-block;
margin-bottom: 4px;
}
</style>
<body>
<div class="row">
<div class="col-md-12">
<div class="btn-group">
<div class="form__group" style="margin-right: 24px;">
<textarea wrap="off" class="form__input disabled-custom horizontal-scroll" style="min-width: 120px;" readonly>https://app.zeplin.io/project/5bb1fdc046eb4d20e8405978/screen/5c18f75217aa3f24677c39a8</textarea>
<label class="form__label">Input 1</label>
</div>
</div>
</div>
<div class="col-md-12">
<div class="btn-group">
<div class="form__group" style="margin-right: 24px;">
<textarea wrap="off" class="form__input disabled-custom horizontal-scroll" style="min-width: 120px;" readonly>30 Points</textarea>
<label for="test_passing_sc" class="form__label">Input 2</label>
</div>
</div>
</div>
</div>
</body>
</html>
I am trying to add an expandable search box to a row of items. I'm using the example here as the core of this. Here is my jsfiddle. I tried to simulate the problem by limiting the widths. All of the style statements are just for formatting it here. The main problem is that I want to give the search div just enough room to display a search icon. And then, when it's moused over, it should expand to allow input. As you can see, it expands but in the wrong direction.
The original code had "float: right !important;" instead of the "position:fixed !important; z-index:100;" I changed it to. I did that thinking I could control the placement. And it worked, sort of. But the result isn't what I want.
In short, the code as provided by the source site works correctly but only when the search icon is on a line by itself. Can it be placed on a line with other elements and still expand as needed?
Here's the code I am using:
<style>
.search-form .form-group {
position:fixed !important;
z-insex:100;
transition: all 0.35s, border-radius 0s;
width: 32px;
height: 32px;
background-color: #fff;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
border-radius: 25px;
border: 1px solid #ccc;
}
.search-form .form-group input.form-control {
padding-right: 20px;
border: 0 none;
background: transparent;
box-shadow: none;
display:block;
}
.search-form .form-group input.form-control::-webkit-input-placeholder {
display: none;
}
.search-form .form-group input.form-control:-moz-placeholder {
/* Firefox 18- */
display: none;
}
.search-form .form-group input.form-control::-moz-placeholder {
/* Firefox 19+ */
display: none;
}
.search-form .form-group input.form-control:-ms-input-placeholder {
display: none;
}
.search-form .form-group:hover,
.search-form .form-group.hover {
width: 100%;
border-radius: 4px 25px 25px 4px;
}
.search-form .form-group span.form-control-feedback {
position: absolute;
top: -1px;
right: -2px;
z-index: 2;
display: block;
width: 34px;
height: 34px;
line-height: 34px;
text-align: center;
color: #3596e0;
left: initial;
font-size: 14px;
}
</style>
<div style="width:250px;border:1px solid">
<div style="display:inline-block;width:100px;border:1px solid;"><img src="example.com/test.png" width="100"></div>
<div style="display:inline-block;width:80px;border:1px solid;vertical-align:top;">A block of text</div>
<div class="search" style="display:inline-block;vertical-align:top;">
<div class="searchbox-margin">
<form action="" class="search-form">
<div class="form-group has-feedback">
<label for="search" class="sr-only">Search</label>
<input type="text" class="form-control" name="keywords" id="search" placeholder="Search">
<span class="glyphicon glyphicon-search form-control-feedback"></span>
</div>
</form>
</div>
</div>
</div>
Try the following code.
.search-form .form-group input.form-control::-webkit-input-placeholder {
display: none;
}
.search-form .form-group input.form-control:-moz-placeholder {
/* Firefox 18- */
display: none;
}
.search-form .form-group input.form-control::-moz-placeholder {
/* Firefox 19+ */
display: none;
}
.search-form .form-group input.form-control:-ms-input-placeholder {
display: none;
}
.search-form .form-group:hover,
.search-form .form-group.hover {
width: 50%;
border-radius: 4px 25px 25px 4px;
/*transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;*/
}
.search-form .form-group span.form-control-feedback {
position: absolute;
top: -1px;
right: -2px;
z-index: 2;
display: block;
width: 34px;
height: 34px;
line-height: 34px;
text-align: center;
color: #3596e0;
left: initial;
font-size: 14px;
}
.search-form .form-group input.form-control {
border: 0 none;
box-shadow: none;
display: block;
height: 27px;
margin-top: 2px;
width: 87%;
padding-right: 20px;
background: transparent;
}
.search-form .form-group {
position: fixed !important;
z-index: 100;
transition: all 0.35s, border-radius 0s;
width: 48px;
height: 32px;
background-color: #fff;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
border-radius: 25px;
border: 1px solid #ccc;
margin-top:2px;
}
<div style="width:250px;border:1px solid">
<div style="display:inline-block;width:100px;border:1px solid;"><img src="example.com/test.png" width="100"></div>
<div style="display:inline-block;width:80px;border:1px solid;vertical-align:top;">A block of text</div>
<div class="search" style="display:inline-block;vertical-align:top;">
<div class="searchbox-margin">
<form action="" class="search-form">
<div class="form-group has-feedback">
<input type="text" class="form-control" name="keywords" id="search" placeholder="Search">
<span class="glyphicon glyphicon-search form-control-feedback"></span>
</div>
</form>
</div>
</div>
</div>
Recently I made a post to see if anyone was able to help me horizontally align my div to the center of my page. After some tweaking I was able to vertically align my LoginBox to where I needed it to be but sadly, I dont seem to be able to move the Username section and Password section to where I would like this to go, I would appreciate any support given and I understand this is probably very simple to achieve but as someone who is pretty new to coding I love to see the help and support if I don't understand something, I've provided the source code below, and I have also provided a jsfiddle incase it is needed. https://jsfiddle.net/BeastFox/36vet66q/
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="main.css">
<link href="https://fonts.googleapis.com/css?family=Raleway:100" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto+Condensed" rel="stylesheet">
</head>
<body>
<div class="LoginBox" style="">
<a class="Login">Login</a>
<input type="text" name="" class="username" placeholder="Username">
<input type="password" name="" class="password" placeholder="Password">
</div>
</body>
</html>
And here is the css.
body,html {
background: repeating-linear-gradient(
to right,
#141517,
#141517 30px,
#1d1f21 30px,
#1d1f21 40px
);
background-size: 100%;
overflow-x: hidden;
overflow-y: hidden;
}
.username {
display: block;
margin: 0 auto;
background: #333;
color: #ccc;
width: 150px;
padding: 6px 15px 6px 5px;
transition: 500ms all ease;
border: 1px solid #333;
margin-bottom: 10px;
text-align: center;
vertical-align: middle;
}
.username:hover {
box-shadow: 0px 0px 4px #000;
}
.password {
padding-top: 30;
text-align: center;
display: block;
margin: 0 auto;
background: #333;
color: #ccc;
width: 150px;
padding: 6px 15px 6px 5px;
transition: 500ms all ease;
border: 1px solid #333;
}
.password:hover {
box-shadow: 0px 0px 4px #000;
}
.LoginBox {
left: 40%;
top: 30%;
position: fixed;
padding-top: 50 auto;
width: 300px;
height: 300px;
margin: 0 auto;
padding: 25px;
background-color: firebrick;
z-index: -3;
box-shadow: 0px 0px 5px #000;
}
.Login {
display: block;
width: 100%;
text-align: center;
font-size: 30px;
font-family: 'Roboto Condensed', sans-serif;
color: #FFF;
}
Thank you for any help that you can provide me with,
Your's most sincerely,
David.
You can align the LoginBox content by...
Wrapping the content in new div.
Adding flexbox properties to LoginBox, which will position the new div.
fiddle
body,
html {
background: repeating-linear-gradient( to right, #141517, #141517 30px, #1d1f21 30px, #1d1f21 40px);
background-size: 100%;
overflow-x: hidden;
overflow-y: hidden;
}
.username {
display: block;
margin: 0 auto;
background: #333;
color: #ccc;
width: 150px;
padding: 6px 15px 6px 5px;
transition: 500ms all ease;
border: 1px solid #333;
margin-bottom: 10px;
text-align: center;
vertical-align: middle;
}
.username:hover {
box-shadow: 0px 0px 4px #000;
}
.password {
padding-top: 30;
text-align: center;
display: block;
margin: 0 auto;
background: #333;
color: #ccc;
width: 150px;
padding: 6px 15px 6px 5px;
transition: 500ms all ease;
border: 1px solid #333;
}
.password:hover {
box-shadow: 0px 0px 4px #000;
}
.LoginBox {
left: 40%;
top: 30%;
position: fixed;
padding-top: 50 auto;
width: 300px;
height: 300px;
margin: 0 auto;
padding: 25px;
background-color: firebrick;
z-index: -3;
box-shadow: 0px 0px 5px #000;
display: flex;
align-items: center;
justify-content: center;
}
.Login {
display: block;
width: 100%;
text-align: center;
font-size: 30px;
font-family: 'Roboto Condensed', sans-serif;
color: #FFF;
margin-bottom: 1em; /* create space between 'Login' and inputs */
}
<div class="LoginBox" style="">
<div class="LoginBox-inner">
<a class="Login">Login</a>
<input type="text" name="" class="username" placeholder="Username">
<input type="password" name="" class="password" placeholder="Password">
</div>
</div>
Changed your css a bit. Added a wrapper element to the fields. Set the parent element(LoginBox) to display:table and element_wrapper to display:table-cell;. Then vertically align the element_wrapper.
<div class="element_wrapper">
<a class="Login">Login</a>
<input type="text" name="" class="username" placeholder="Username">
<input type="password" name="" class="password" placeholder="Password">
</div>
Refer this fiddle https://jsfiddle.net/07753vwx/