How do I style text fields in Safari and Chrome - html

I haven't tested it on IE quite yet.
I want to style the background image and text box shape as well as borders for my search bar on my site, [dead site].
If you visit it on Firefox or Opera and see the search bar on the left column, that's what I am going for. Now if you visit it on Safari or Chrome, you should see that it is replaced by their default input text field, which makes the text illegible.
How do I style my text-box even on these browsers?

To be clear, on your site you are actually styling a search field and not a text field.
<input type="search"> <!-- This is what you have -->
vs
<input type="text">
To remove the default styling and allow your css properties to work you need to change the -webkit-appearance property. This should do the trick:
#s {
min-width:98%;
background-color:#2a2a2a;
color:#d3d3d3;
border:2px solid #000000;
font-size:.85 em;
height:1.9em;
display:inline !important;
border-radius:5px 5px 5px 5px;
outline:none;
-webkit-appearance: none; /* add this */
}

style.css
body {
background: #999 url(your_image_here.jpg);
}
.search {
width: 295px; /* 300px less the 5px of left padding*/
height: 30px;
line-height: 30px; /* same as height, then you can vertically align the text in the middle*/
vertical-align: middle;
font-size: 24px; /* this gives 3px at the top and bottom */
background-color:#ccc; /* a light grey background in the text box */
color:#333; /* dark grey font colour */
padding-left: 5px; /* spacing (padding) within the left hand side of the text box */
border: 1px solid #000; /* 1px wide black border around the text box */
display:inline !important;
border-radius:5px 5px 5px 5px; /* slightly rounded corners, the order of the values is TOP RIGHT BOTTOM LEFT */
outline:none;
-webkit-appearance: none; /* this removed the default styling */
}
index.html
<input type="text" class="search" value="search"> <!-- I've given the text box a value (search) so that you can test your css edits quickly without having to type in a value every time you refresh the page -->
I think that this answers your question. Get back to me in the comments if I can be of any further assistance.
Here is a link to jsfiddle where you can do a little rapid prototyping of my example.
http://jsfiddle.net/mstnorris/nVDbA/

Related

html display textbox as a blankline css bootstrap

I am new to using front-end designs. I have tried to convert a input textbox of type number as a blankline. Added below css style
input[type=number] {
background: transparent;
border: none;
border-bottom: 1px solid #000000;
outline: none;
}
And using bootstrap form-control css for more responsiveness
class="form-control form-control-sm"
But my screen shows the line with navigation bar end of the line as below. Also I need to limit max of 4 numbers only on this number box ? How to set fixed size and remove the unnecessary bar on the right side?
The bar is called a "spinner", you remove it like this:
/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
/* Firefox */
input[type=number] {
-moz-appearance: textfield;
}
You can limit the number of characters with the maxlength="4" attribute on the input (you can't do that with CSS).
Additionally, if you don't want those little curves at either side, make sure you add border-radius: 0; to your input.

HTML Textarea style scrollbar corner borders

I am trying to style the Textarea's resizer in the dark mode of my website so that it is not a white block in an otherwise dark website. As such, I tried to both use ::-webkit-scrollbar-corner and ::-webkit-resizer, although the first one leaves white corners (see screenshot), while the other one removes the characteristic two lines from the resizer. I know these changes will affect only Webkit and Blink based browsers, thus not IE, older versions of Edge and Firefox. Is there a way I can style ::-webkit-scrollbar-corner to avoid having those white corners? I want to avoid adding custom wrappers with custom scrollbars as much as I can, as it would take me way longer and add unnecessary complexity.
Here is a minimal example to reproduce the issue:
::-webkit-scrollbar-corner {
background-color: red;
}
::-webkit-scrollbar {
background-color: green;
}
textarea {
background-color: black;
color: white;
}
<textarea>
Hello
World
</textarea>
Update: To clarify, I still need the textareas to be resizable, I want to know if there is a way to remove the white top and left borders from the resizer without styling ::-webkit-resizer which would mean using an SVG to have the two lines typical of the resizer, as in the image.
It's because the textarea can be resized, so the bottom right corner is resizing box.
You can remove it by setting the resize property of textarea as none;`
I think you can do like this.
::-webkit-scrollbar-corner {
background-color: red;
}
::-webkit-scrollbar {
background-color: green;
}
::-webkit-scrollbar-thumb {
background-color: #002200;
border-radius: 20px;
border: 3px solid transparent;
background-clip: padding-box;
}
textarea {
background-color: black;
color: white;
resize: none;
width: 100%;
height: 100px;
}
<textarea>
Hello
World
</textarea>

Input text type not shown in safari

I have something in this code that breaks my <input type = "text"> from showing in safari, Im not sure what it is can anyone help me?
input[type="text"]{
border: 3px solid #eae9ef;
border-radius: 3px !important;
box-sizing: border-box !important;
background: rgba(255,255,255,0) !important;
padding:1.5em 1em !important;
}
The issue is because of the padding 1.5em 1em, how can I fix it,I need the padding to make the input box bigger, but with it my text disappears.
Give a height to the text input instead of adding padding. The padding will limit the space inside the input so the text won't show.

How to get cross-browser form `fieldset` content height in % (with legend)

I want to set in % the height of a div included in a fieldset,
but browsers don't calculate the same way the inside height of the fieldset when you use legend !
Firefox: height: 100% consider the height of the legend: it's ok.
Chrome: height: 100% does NOT consider the height of the legend: it overflows.
Internet Explorer: height: 100% does NOT consider the height of the legend: it overflows.
1. Do you know a clean solution to have the same result in the 3 browsers?
2. Which is right compared to W3C recommendations?
Here is the code used to make the test:
<html>
<body>
<fieldset style="height:60px;width:150px;">
<legend>Legend</legend>
<div style="height:100%;width:100%;margin:0;padding:0;background-color:#FF0000;">
DIV : height 100%
</div>
</fieldset>
</body>
</html>
This is an interesting case.
To your 2nd question: It might arise out of W3C HTML5 standard spec being very vague of the visual representation of <legend> element. There has been a long history of browser inconsistencies around <legend>.
To answer your question 1. and come up with a cross-browser consistent position of legend:
In order to get the miscalculation resolved, you have to remove legend from the content flow, for example by adding float to it. Then you need to reposition it relatively and 456bereastreet.com came up with a sibling selector clearing the float immediately after.
Demo:
https://codepen.io/Volker_E/full/zqPjrK/
CSS code on top of your inline styles:
fieldset {
position: relative;
margin: 0;
border: 1px solid #000;
padding: 0;
}
legend {
float: left;
margin-top: -1em;
line-height: 1em;
}
legend + * { /* #link: http://www.456bereastreet.com/archive/201302/fieldset_legend_border-radius_and_box-shadow/ */
clear: both;
}
It is indeed browser differences (bugs?) or vague spec, which don't allow to style it consistently without taking legend out of flow.
This is an old topic, but still can be useful to someone (my solution is below).
I searched all day for a solution and did not find it. I want to display it correctly in chrome, firefox, edge, opera and IE11 (which will probably also work on IE10).
"Float" or "position: absolute;" does not solve the problem for me, because it removes the transparent background of the legend. I want to keep it on the fieldset 's border and also keep its transparent background (so as one does not see the border beneath it).
I tried with negative top/bottom margins, but then I have a problem in firefox (which infact is the only one who displays the legend correctly).
How I solved it:
I just put "line-height: 0;" (no unit) on my legend and now it displays it correctly.
This way I managed to get the full height of the filedset, from top to bottom border (without the bottom overflow), with overlapping the content with the legend.
Now this can be solved with filedset's padding (detach the content from the label and/or vertically center it with top/bottom padding on the fieldset etc.).
If you need a border on the legend, you can do it with an absolutely positioned pseudo-element (width 100%, height in px/em/rem, top 50%, left: 0, translateY -50%), because padding on legend (even with negative margins) will bring back the same problem.
I tested this in all above-mentioned browsers, on Windows 8.1.
I have not tested it on mobile or safari. I will test it on several mobile browsers (android), but if there's someone to check it on safari, it would be nice.
I was going crazy with the same issue and I've found a css snippet for normalizing fieldsets, And it goes right, in my case I had to remove some properties that are unnecesary, I've removed the old IE versions support too.
this is what I've used to solve my problem commenting unnecesary lines and IE support:
fieldset {
margin: 0px; padding: 0px; display: block; position: relative; width: 100%;
//%border-top: none !important; /* for IE7, does not work with Webkit */
//_padding-top: 3em; /* for IE6 */
}
fieldset > * {
width: auto;
//%width: auto !important; /* for IE7 */
// margin-left: 1.5em; /* emulating fieldset padding-left */
// margin-left: 1.5em !important; /* for IE7 */
}
fieldset *:first-child + * {
// margin-top: 3em; /* emulating fieldset padding-top */
}
fieldset:last-child {
margin-bottom: 1.5em; } /* emulating fieldset pading-bottom */
legend {
width: 100%;
//%width: 100% !important; /* for IE7 */
position: absolute;
top: -1px; left: -1px; /* hide the fieldset border */
margin: 0px !important; /* suppress all margin rules */
line-height: 2em; /* emulating padding-top/bottom */
text-indent: 1.5em; /* emulating padding-left */
//%left: -8px;
} /* for IE7 */
/* user format */
fieldset, legend {
border: 1px solid #ddd;
background-color: #eee;
-moz-border-radius-topleft: 5px;
border-top-left-radius: 5px;
-moz-border-radius-topright: 5px;
border-top-right-radius: 5px;
}
legend {
font-weight: normal;
font-style: italic;
font-size: 1.2em;
text-shadow: #fff 1px 1px 1px; }
fieldset {
background-color: #f7f7f7;
width: 360px;
-moz-border-radius-bottomleft: 5px;
border-bottom-left-radius: 5px;
-moz-border-radius-bottomright: 5px;
border-bottom-right-radius: 5px; }
This is the first time I try to help on stackoverflow, usually I only read the answers. Well the original and Snippet is on https://gist.github.com/paranoiq/827956/31303920733a98805cd46915c249ec788cfca6a6
Really, really usefull to understand how fieldsets works around different browsers, hope it can save others from frustration.
Pd: Sorry if my english isn't good enough, but hope you can understand it perfectly

Tables inside a div? IE7 compatability issue - looking for a resource to expand knowledge on how to deal with IE7 problems

I'm currently doing the redesign for this site: http://www.palosverdes.com/rpv2012/ and have run into a problem with repeating a gradient inside a div (cnews). The issue is that when the gradient is repeated on IE7, there is a color problem. It almost seems as if the blue on the image is lightened somehow. When I set the attribute to no-repeat, I don't get the rounded edges effect I'd like the achieve.
Here's the code in question:
<div class="box-noshadow" id="cnews">
<div id="spotlight">
</div><!--spotlight-->
<div onmouseout="document.getElementById('stop').start();" onmouseover="document.getElementById('stop').stop();" id="stopmarquee">
<div align="center" id="toptitle">
CITY NEWS & EVENTS
</div><!--toptitle-->
<div id="cnewscontainer">
<iframe align="middle" width="400px" scrolling="no" height="100px" frameborder="0" src="scroll_file_b/break2.cfm"></iframe>
</div><!--cnewscontainer-->
</div><!--stopmarquee-->
</div><!--cnews-->
and the relevant CSS:
#cnews {
width: 100%;
background-image:url(images/cnews-back.jpg);
float: left;
padding: 5px;
font-family:Arial, Helvetica, sans-serif;
overflow:hidden;}
#spotlight {
width: 50%;
height: 200px;
background-color: yellow;
float: right;
padding: 5px;}
.box {-moz-border-radius: 15px; /* Firefox */
-webkit-border-radius: 15px; /* Safari and Chrome */
border-radius: 15px; /* Opera 10.5+, future browsers, and now also Internet Explorer 6+ using IE-CSS3 */
-moz-box-shadow: 10px 10px 20px #000; /* Firefox */
-webkit-box-shadow: 10px 10px 20px #000; /* Safari and Chrome */
box-shadow: 10px 10px 20px #000; /* Opera 10.5+, future browsers and IE6+ using IE-CSS3 */
behavior: url(PIE.htc); /* This lets IE know to call the script on all elements which get the 'box' class */}
What solution can I pursue that will allow this to still render correctly in modern browsers as well? Should I use IE7-specific CSS?
Also, where can I look to see what HTML/CSS ie7 has problems interpreting compared to modern browsers?
Your width:50% on your stopmarquee is causing that item to drop down lower in IE7, instead of rising up next to the right floated spotlight div. This is causing your cnews container to expand down further, which is then causing your background image to repeat in the 'y' direction (like 3rror404 stated in his comment).
Your background image itself has a color shift within it, so that the top of the image is lighter than the lower part of the image, thus you are getting a lighter look when the image repeats in the 'y' direction.
You can correct the stopmarquee position by changing to width: 49% (which I don't think will hurt your layout), and that will probably resolve your issue. Otherwise, make the background image a solid color so that a repeat does not cause the issue.