Input field doesn't render well in Safari - html

I've been checking an input field across various browsers. It only doesn't render well in Safari for some reason. It's ignoring the padding assigned to itself.
Do you know any issue caused by that?
Below there is the form and its styling.
Thanks
<form class="search" name="searchCity" ng-submit="search(city)">
<input class="search__field" name="searchField" type="search" title="Please enter city name" required placeholder="City to find" ng-model="city" ng-pattern ="regex"/>
<button ng-disabled="searchCity.$invalid" class="search__button" type="submit"><img src="./img/search_icon.gif" alt="Search city" /></button>
</form>
//Form elements style global
form{
font-size:1.2em;
width:100%;
textarea{
display: block;
margin: 20px 0;
width: 100%;
height: 200px;
padding: 10px;
}
select{
padding: 13px;
-webkit-appearance: menulist-button;
height: 45px;
}
input{
&[type="checkbox"], &[type="radio"]{
display: none;
+ label{
position: relative;
cursor: pointer;
vertical-align: middle;
}
&:before{
content: "";
border: 1px solid gray;
background-color: white;
border-radius: 50%;
width: 17px;
height: 17px;
display: inline-block;
vertical-align: middle;
margin-right: 5px;
}
}
&[type="checkbox"]{
+ label{
&:before{
border-radius: 0;
margin-right: 10px;
}
}
}
&:checked{
+ label:after{
content: "";
background-color: green;
border-radius: 50%;
width: 9px;
height: 9px;
position: absolute;
left: 5px;
top: 5px;
}
}
&[type="text"],
&[type="search"],
&[type="password"],
&[type="number"]{
padding: 13px;
border: solid 1px #a4a4a4;
}
}
}

Input type search isn't supported in a few browsers but it should be supported in Safari, maybe try using input type text since it behaves the same as search.

Related

Putting search icon in search input, then centering both in page

I've managed to get the search icon IN the input field, and can center the input field with margin: 0 auto and displaying it to block (but this keeps from the icon being in the field and keeps it at the right of the page, since it's on block - yet it's the only way I've managed to center it). New to HTML/CSS, so is there a proper way to do this? Looking to learn.
Currently have this code:
#import url("//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css");
.search {
position: relative;
color: #aaa;
font-size: 16px;
}
.search input {
width: 500px;
height: 32px;
background: #fcfcfc;
border: 0;
border-bottom: 5px solid #000;
outline: none;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
margin: 0 auto;
}
.search input {
text-indent: 32px;
}
.search .fa-search {
position: absolute;
top: 10px;
left: 10px;
}
<div class="search">
<span class="fa fa-search"></span>
<input placeholder="Search term" id="search" class="keyword">
</div>
The input is an inline element, consider centering the the wrapper which is a div (block element) on where you can use margin:auto. You may also use max-width to make it responsive on small screen:
#import url("//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css");
.search {
position: relative;
color: #aaa;
font-size: 16px;
max-width: 500px;
width:100%;
margin:0 auto;
}
.search input {
width:100%;
height: 32px;
background: #fcfcfc;
border: 0;
border-bottom: 5px solid #000;
outline: none;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
.search input {
text-indent: 32px;
}
.search .fa-search {
position: absolute;
top: 10px;
left: 10px;
}
<div class="search">
<span class="fa fa-search"></span>
<input placeholder="Search term" id="search" class="keyword">
</div>

Styled css do not appear in firefox

I have a checkbox that I have styled accordingly. Like this :
input[type=checkbox] {
transform: scale(1.3);
}
input[type=checkbox] {
width: 30px;
height: 30px;
margin-right: 15px;
cursor: pointer;
font-size: 17px;
visibility: hidden;
}
input[type=checkbox]:after {
content: " ";
background-color: rgba(224, 214, 214, 0.877);
display: inline-block;
margin-left: 10px;
padding-bottom: 5px;
color: #fff;
width: 22px;
height: 25px;
visibility: visible;
border: 1px solid transparent;
padding-left: 3px;
border-radius: 5px;
}
input[type=checkbox]:checked:after {
content: "\2714";
padding: -5px;
background: red;
font-weight: bold;
}
<input type="checkbox" [(ngModel)]="Option1" />
<p>Option1</p>
I tested this and it worked in Chrome and Opera, but I forgot to check Firefox.
Now I see that the checkboxes don't appear there at all.
I understand it is an issue of using :after for checkbox, but how do I fix this ?
So that the same checkbox appears styled on the browsers?.
I am uncertain of what to do so that I keep the design.
Thank you.
Read these specifications
:before and :after should only work on the element which can act as a
container of content. cannot contain any content so it should
not support those pseudo-elements. Chrome supports because it does not
follow the spec
However you can use <span> tag next to input tag to achieve this like below. It will work on firefox as well
body {
font: 13px Verdana;
}
label {
position: relative;
display: inline-block;
text-align: center;
}
label span {
display: block;
margin-top: 10px;
cursor: pointer;
}
input[type=checkbox] {
width: 30px;
height: 30px;
cursor: pointer;
margin: 0;
opacity: 0;
}
input[type=checkbox]+span:after {
content: "";
background-color: rgba(224, 214, 214, 0.877);
color: #fff;
width: 30px;
height: 30px;
border-radius: 5px;
position: absolute;
top: 0;
left: 50%;
transform: translateX(-50%);
line-height: 30px;
}
input[type=checkbox]:checked+span:after {
content: "\2714";
background: red;
}
<label>
<input type="checkbox" [(ngModel)]="Option1" />
<span>Option1</span>
</label>

CSS content Property not working as expected in firefox

What i am doing is that in search box when user enter a search term, i display a close button ('x' character to be specific, embedded as content after reset button) to clear the contents of search box.
It works fine in both Chrome and IE but not in firefox.
Any kind of help would be highly appreciated.
.search-box,.close-icon,.search-wrapper {
position: relative;
padding: 10px;
}
.search-wrapper {
width: 500px;
margin: auto;
margin-top: 50px;
}
.search-box:focus {
box-shadow: 0 0 15px 5px #b0e0ee;
border: 2px solid #bebede;
}
.close-icon {
border:1px solid transparent;
background-color: transparent;
display: inline-block;
vertical-align: middle;
outline: 0;
cursor: pointer;
}
.close-icon:after {
content: "X";
display: block;
width: 15px;
height: 15px;
position: absolute;
z-index:1;
right: 35px;
top: 0;
bottom: 0;
margin: auto;
padding: 2px;
border-radius: 50%;
text-align: center;
color: black;
font-weight: normal;
font-size: 12px;
cursor: pointer;
}
.search-box:not(:valid) ~ .close-icon {
display: none;
}
<div class="search-wrapper">
<form>
<input type="text" name="focus" required class="search-box" placeholder="Enter search term" />
<button class="close-icon" type="reset"></button>
</form>
</div>
This code should help you
.search-box,.search-wrapper {
position: relative;
padding: 10px;
}
.search-wrapper {
width: 500px;
margin: auto;
margin-top: 50px;
}
.search-box
{
width:300px;
}
.search-box:focus {
box-shadow: 0 0 15px 5px #b0e0ee;
border: 2px solid #bebede;
}
.close-icon {
border:1px solid transparent;
background-color: transparent,
display: inline-block;
vertical-align: middle;
outline: 0;
position: absolute;
top:19px;
left:305px;
z-index:1;
padding: 1px 2px;
border-radius: 50%;
text-align: center;
color: black;
font-weight: normal;
font-size: 12px;
cursor: pointer;
}
.search-box:not(:valid) ~ .close-icon {
display: none;
}
<div class="search-wrapper">
<form>
<input type="text" name="focus" required class="search-box" placeholder="Enter search term" />
<button class="close-icon" type="reset">X</button>
</form>
</div>
NOTE : set your .search-box width and according to it set left of your .close-icon
Try this code: Hope this solve your problem. Adjust "outer_box" class for width.
<style>
.search-box, .search-wrapper {
padding: 10px;
box-sizing: border-box;
}
.search-box {
position:relative;
width:100%;
}
.outer_boxs{
position:relative;
width:60%;
}
.search-wrapper {
width: 500px;
margin: auto;
margin-top: 50px;
}
.search-box:focus {
box-shadow: 0 0 15px 5px #b0e0ee;
border: 2px solid #bebede;
}
.close-icon {
border:1px solid transparent;
background-color: transparent,
display: inline-block;
vertical-align: middle;
outline: 0;
cursor: pointer;
position: absolute;
right:5px;
top: 10px;
background:#f2f2f2;
}
.search-box:not(:valid) ~ .close-icon {
display: none;
}
</style>
<div class="search-wrapper">
<form>
<div class="outer_boxs" >
<input type="text" name="focus" required class="search-box" placeholder="Enter search term" />
<button class="close-icon" type="reset">X</button>
</div>
</form>
</div>

How to use position:relative to different browsers? Or is it not the best way?

I'm creating static web site and sometimes use position:relative. And when I tested my page on different browsers I got different displays of some elements like 1-2 pixels higher or lower.
How I can solve the problem or I should use something else?
Thought about some gulp package but didn't find anything.
Example.
HTML:
<p id="search-form-menu">
<input type="search" name="search-input" placeholder="Поиск">
<input type="submit" value="">
</p>
CSS:
input[type='search'] {
height: 35px;
width: 250px;
border: 0px;
border-radius: 5px;
position: relative;
top: -10px;
padding-left: 15px;
padding-right: 45px;
}
input[type='submit'] {
height: 35px;
width: 45px;
background-color: white;
border: 0;
border-left: 3px solid #d1d1d1;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
position: relative;
top: -10px;
left: -47px;
background-image:url("../image/search-loop-2.svg");
background-position: center;
background-repeat:no-repeat;
}
Why not use float style on the submit input?
<p id="search-form-menu">
<input type="search" name="search-input" placeholder="Поиск"/>
<input type="submit" value=""/>
</p>
css
p#search-form-menu{
width: 250px;
height: 35px;
}
input[type='search'] {
display: inline-block;
height: 35px;
width: 205px;
border: 0px;
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
padding-left: 15px;
padding-right: 15px;
}
input[type='submit'] {
display: block;
float: right;
height: 35px;
width: 45px;
background-color: white;
border: 0;
top:10px;
border-left: 3px solid #d1d1d1;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
background-image:url("../image/search-loop-2.svg");
background-position: center;
background-repeat:no-repeat;
}
created a fiddle and got this to work in chrome and ie.
https://jsfiddle.net/1r8a2u87/2/
There should be no need to use positioning here at all.
Just box-sizing and vertical-align.
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
background: #c0ffee;
}
input[type='search'] {
height: 35px;
width: 250px;
border-radius: 5px;
border: none;
}
input[type='submit'] {
height: 35px;
width: 45px;
background-color: white;
border: none;
border-left: 3px solid #d1d1d1;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
vertical-align: middle;
}
<p id="search-form-menu">
<input type="search" name="search-input" placeholder="Поиск">
<input type="submit" value="Go">
</p>

Search button with image in background height inconsistencies

I made a search bar with a button that has an image as a background. I really can't get the button and the search bar to be the same height on all the browsers and devices.
My HMTL:
<form action="test.php">
<input type="search" placeholder="Indiquer un département...">
<input type="image" name="search" src="./img/loupe.png">
</form>
My CSS:
.search form input[type=search] {
position: relative;
left: 1.8em;
width: 65%;
padding: 0.87em;
margin-top: 3em;
background-color: #ffffff;
float: left;
-webkit-appearance: none
}
.search form input[type=search]:hover {
border: 1px #a1a1a1 solid;
}
.search form input[type="image"] {
height: 1.96em;
display: inline-block;
position: relative;
padding: 0.5em 20px;
left: 1.8em;
margin-top: 3em;
background-color: #4689f5;
color: #ffffff;
border: 1px #2f78eb solid;
cursor: pointer;
-webkit-appearance: none;
}
.search form input[type="image"]:hover {
background-color: #367ae8;
border: 1px #2d59b5 solid;
}
Thank you.
Try vertical-align: middle in your input[type="image"].