Inconsistency in styling Options list compared to Input box - css

I have the following code in which I am seeing an inconsistency in styling between the styling of the placeholder text in the email input box and the styling of the content of the options box, this is especially seen in Firefox where the content of the options box appears bold in comparison to the "Email" placeholder text. I'm wondering if it is possible to get a more consistent look between the two whilst keeping the same font family and font size.
html:
<input type="email" name="email" placeholder="Email">
<br />
<select>
<option selected>Option 1</option>
</select>
css:
input[type=email] {
width: 320px;
height: 20px;
background-color: #E9F2F9;
border: none;
margin-top: 20px;
margin-left: 20px;
padding-top: 8px;
padding-bottom: 12px;
padding-left: 9px;
position:relative;
}
select {
font-size: 15px;
font-family: 'Roboto', sans-serif;
font-weight: 400;
line-height: 20px;
letter-spacing: -0.02px;
width:329px;
height:40px;
padding-left:9px;
padding-top:8px;
padding-bottom:12px;
background: #E9F2F9;
color:#666666;
border:none;
display: inline-block;
cursor:pointer;
position: relative;
margin-left: 20px;
margin-top: 20px;
}

If you want to adjust the placeholder styling you can use the pesudo-class selector ::placeholder in addition to the input selector input[type=email].
If you want to adjust the option styling you can use the option.
This way you can synchronize the styling of the elements:
option, input[type=email]::placeholder {
font-family: Helvetica;
text-transform: Uppercase;
font-size: 1em;
background-color:yellow;
}
Of course you can use whatever properties you wish. This will allow you to override any browser defaults which might affect the look differently.
Here is some more info about pseudo-classes:
https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes
They can be extremely useful so going over some of them to at least get a sense of what's available is highly recommended.
For some more help with cross-browser quirks i also recommend checking out the normalize library:
http://nicolasgallagher.com/about-normalize-css/
EDIT:
select, option, input[type=email]::placeholder {
color: black;
font-family: Helvetica;
font-size: 16px;
font-weight: 500;
text-transform: capitalize;
}

Related

How override input CSS styles for ng2-date-picker

I am trying to style the Angular2 ng2-date-picker (link) component and would appreciate any guidance.
I cannot find any documents regarding the styling of this component online, and there is only one similar question on stackoverflow, which does not help me much.
I would like to style the actual `<input >` element inline with the below CSS:
.af-input {
font-size: 20px;
font-weight: normal;
font-stretch: normal;
font-style: normal;
letter-spacing: normal;
border-radius: 15px;
border: solid 1px $af-brownish-grey;
background-color: transparent;
color: $af-brownish-grey;
}
This is my setup in my HTML/View:
<div class="date-picker">
<dp-date-picker theme="dp-material" [(ngModel)]="selectedDate" mode='daytime' [config]='config'></dp-date-picker>
</div>
These are the CSS attributes I see when inspecting the element in the browser:
dp-date-picker.dp-material .dp-picker-input {
box-sizing: border-box;
height: 30px;
width: 213px;
font-size: 13px;
outline: 0;
}
button, input {
overflow: visible;
}
button, input, optgroup, select, textarea {
margin: 0;
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
This is the HTML code when inspecting the ng-date-picker element:
<div _ngcontent-oyd-c55="" class="date-picker">
<dp-date-picker _ngcontent-oyd-c55="" theme="dp-material" mode="daytime" ng-reflect-theme="dp-material"
ng-reflect-mode="daytime" ng-reflect-config="[object Object]" class="dp-material ng-valid ng-dirty ng-touched"
ng-reflect-model="Fri Jun 19 2020 13:50:18 GMT+0">
<div ng-reflect-ng-class="[object Object]" class="dp-open">
<div class="dp-input-container"><input type="text" class="dp-picker-input ng-pristine ng-valid ng-touched"
ng-reflect-is-disabled="false" ng-reflect-model="2020-06-19" placeholder=""></div>
</div>
</dp-date-picker>
</div>
Thank you in advance!
It doesn't seem like this component allows configurations styling-wise.
You'll need to manually override existing styling with css. Just inspect the element and find the required selectors you want to override.
As this is an external component, make sure to wrap your styles with ::ng-deep { ... }, so that your styles get placed at the top of the DOM tree and can override initial styling.
As per Berk Kurkcuoglu's answer, I solved my styling challenge using ::ng-deep { ... }.
This is my specific implementation to style the <input >:
.date-picker {
::ng-deep {
input {
&:last-child {
font-family: $af-default-font;
font-size: 20px;
font-weight: normal;
font-stretch: normal;
font-style: normal;
letter-spacing: normal;
border-radius: 15px;
border: solid 1px $af-brownish-grey;
background-color: transparent;
color: $af-brownish-grey;
}
}
}
}
*See also this answer for more details.
I hope this helps someone else!

First-letter pseudo-element not working properly with quote sign in CSS

I am trying to style a pull-quote div tag. I want to style the quote mark " so it is bigger than the rest of the statement.
I thought of using the first-letter pseudo-element. However when I did so, it did not work properly. Here are the cases I tried:
If I wrote the sentence like this: "This is a test,(with no spaced between the "and theT then both the "Tappear big.
If I wrote it with a space between them, none of them get bigger.
My question is: is there a way to get the " only to be bigger?
Here is the html code I used: <div class="pullquote-right">"this is a test</div>
The css:
.pullquote-right {
display: inline-block;
max-width: 350px;
float: right;
padding-left: 15px;
margin-left: 25px;
border-left: #3b5998;
border-left-width: thick;
border-left-style: solid;
font-style: italic;
color: darkgray;
font-size:115%;}
.pullquote-right::first-letter {font-size: 200%;}
Thanks.
An option would be to use the ::before and ::after pseudo elements.
.quote::before,
.quote::after {
content: "\0022";
font-size: 2em;
font-weight: bold;
color: green;
vertical-align: -.3em;
}
<p class="quote">This is a great quote</p>
The first-letter pseudo class refers to the first letter and the punctuation directly preceding it. Reference:
https://developer.mozilla.org/en-US/docs/Web/CSS/::first-letter
I think the easiest way to do what you want might be to put a span tag around the punctuation you want to make bigger and style that from the css.
Or you can check out this work-around: https://css-tricks.com/snippets/css/simple-and-nice-blockquote-styling/
I ended up combining the two answers to be able to use the div tag and not neet to add extre <p></p>as follows:
.pullquote-left {
display: inline-block;
max-width: 350px;
float: left;
padding: 20px;
margin-left: 15px;
border-left: #3b5998;
border-left-width: thick;
border-left-style: solid;
font-style: italic;
color: darkgray;
font-size: 110%;
background-color: white;
box-shadow: 5px 5px 5px #888888;
text-align: center;
}
.pullquote-left::before {
font-size: 2em;
font-weight: bold;
content: "\201C";
}
<div class="pullquote-left">This is the final result.</div>

Exclude pseudo elements from hover

How do I exclude pseudo-elements like :before and :after from being changed by selectors like for example: :hover?
Maybe there's some sort of 'main pseudo element' that I'm not aware of?
I've tried using CSS3 :not() statement but this didn't work.
Using: .facebook:hover:before {color: black;} works fine, but I'm sure that there's a better solution.
Example:
I want the Facebook logo to remain black and change the texts color.
body {
background: #F7F7F7;
margin: 0px;
}
.share-button {
background: #FFFFFF;
border: 1px solid #D8D8D8;
display: inline-block;
font-family: 'Open Sans';
font-weight: 600;
font-size: 12px;
text-transform: uppercase;
letter-spacing: 2px;
margin: 0px;
padding: 12px 24px 12px 12px;
transition: color 1s;
}
.facebook:before {
display: inline-block;
height: auto;
font-family: 'FontAwesome';
font-size: 12px;
padding-right: 12px;
width: auto;
content: '\f09a';
}
.share-button:hover {
color: #374D8D;
}
<button class="share-button facebook">
Share on facebook
</button>
The problem here is not that the pseudo-element is being "matched" by the :hover selector per se, but that it is inheriting the color property from the corresponding CSS rule on the element.
That is the reason why you need to set it explicitly on the :before pseudo-element — you cannot block inheritance using a selector, or using a style on the parent or originating element.

Vertical alignment of submit button using CSS HTML

I am having trouble getting my submit button to display in line with my inputs in internet explorer. The alignment is fine in safari and firefox but IE is dropping the button down about 5px. Any ideas why this is happening or how i can fix it?
The url is http://www.menslifestyles.com
click subscribe at the top of the page the form will pop in.
The two inputs line up straight but in ie the submit button doesn't align!
-------html-------
<div id="subscribe">
<form id="subscribeform" method="post" action="/maillists/subscribe" accept-charset="utf-8">
<div style="display:none;"><input type="hidden" name="_method" value="POST"></div>
<label for="MaillistName">Name</label><input name="data[Maillist][name]" type="text" maxlength="255" id="MaillistName">
<label for="MaillistEmail">Email</label><input name="data[Maillist][email]" type="text" maxlength="500" id="MaillistEmail">
<input type="submit" value="Submit">X
</form></div>
-----css-------
#subscribe{
width:620px;
position:absolute;
top:25px;
left:50%;
margin-left:-120px;
overflow: auto;
z-index: 1000;
background: #ffffff;
color:#6e6e6e;
font-size: 10px;
text-transform: uppercase;
font-family: Helvetica, Verdana;
}
#subscribe input{
border: 1px solid #e5e5e5;
display: inline;
height: 12px;
color:#cccccc;
width: 215px;
}
#subscribe input[type="button"], #subscribe input[type="submit"]{
clear:both;
padding:3px, 0px;
-webkit-appearance: none;
font-family: Helvetica, Verdana;
background-color:#cccccc;
text-align:center;
color: #3c3c3c;
font-size:10px;
text-transform: uppercase;
border: none;
cursor: pointer;
display: inline;
height:15px;
width:60px;
position:relative;
margin-left:5px;
}
#subscribe form{
margin:0px;
padding:0px;
}
#subscribe label{
display: inline;
font-size: 10px;
}
#subscribe a{
text-decoration: none;
color: #cccccc;
}
#subscribe #closelink{
padding:0 5px;
}
In your css for #subscribe input[type="button"], #subscribe input[type="submit"] try to add vertical-align: top;
You should set padding and margin explicitly, some browsers have different defaults which will mess things up. So margin-left:5px; becomes margin: 0 0 0 3px;
Forms are also just inconsistent generally, you may want to try and absolutely positioning the submit button, in which case give #subscribe position:relative, and the submit button position:absolute; right:0px; top:0px;
In the future you can get around default browser values, and get a more consistent look by setting default values in your stylesheet , see here for a reset stylesheet that you can include. (If you include this now it might throw a few things out)
In this css rule
#subscribe input[type="button"], #subscribe input[type="submit"]
Change
position:relative
to
position:absolute
Should do the trick. Tested in IE 8 and works.
Submit button seem to have different default margin and padding values in different browsers.
I assume this must be in some reset Stylesheet as this is not the only annoying cross browser "default" values discrepancy. When is the web going to standardize this is another subject.
This is how we do it:
#searchForm {
position: relative; // you must keep this
font-weight: normal;
font-family: Arial, Helvetica, sans-serif;
margin-bottom: 30px;
}
input#searchBtn{
padding: 0; // you must keep this
margin: 0; // you must keep this
position: absolute; // you must keep this
left: 203px; // you can change this
top: 2px;
height: 24px;
width: 42px; // you can change this
font-size: 14px;
background: url(http://yourDomain/img/yourPrettySearchIcon.png) buttonface no-repeat 9px 1px;
}
<form id="searchForm" name="mySearchForm" action="myPage.html" method="post">
<input name="searchBtn" value="" id="searchBtn" type="submit"/>
</form>
I noticed very small discrepancies between IE8, Firefox and GChrome but there may be in other browsers.
The form here has its position set to "relative" so that when I set the button's position to absolute, the button position itself relatively to the searchForm.

CSS heading while using line-height to shift border?

I'm using the following CSS:
h2 {
font-weight: normal;
border-bottom: 1px solid #DDD;
font-size: 1.6em;
font-style: italic;
}
h2 span {
position: absolute;
top: 7px;
padding-right: 6px;
background-color: #F9F9EE;
}
When used like:
<h2><span>abc</span></h2>
Gives the following effect:
abc ------------------
The text 'abc' is the heading content while the dashed line is the border being shifted. The following approach works well so long as you only use it once on the page. My question is, how can I achievement the same effect without using absolute positioning or even perhaps line-height since I suspect either or both are the culprits.
I do remember seeing the same effect being used on a few blogs but the url slips my mind.
Thank you. :)
As Rory mentioned, using position relative on the H2 tag solves the problem without the use of an image.
h2 {
font-weight: normal;
border-bottom: 1px solid #DDD;
font-size: 1.6em;
font-style: italic;
position:relative;
}
h2 span {
position: absolute;
top: -0.8em;
padding-right: 6px;
background-color: #F9F9EE;
}
This works in the three browsers I use for testing (IE, Firefox, and Chrome).
I'm not entirely sure what you're trying to do and what the problem is exactly, but adding position: relative; to the h2 style will create a positioning container in which the span position: absolute; will calculate its values from.
I don't see the effect that you described in Firefox, only in IE6.
One way you could achieve this effect is to use a single pixel background image, tiled horizontally at 50% of the height of the div. It's not as nice, since you do have to use an image, but it should look how you want without affecting the HTML.
I'd suggest something like:
h2 {
font-weight: normal;
font-size: 1.6em;
font-style: italic;
background: url(pixel.png) repeat-x 0% 50%;
}
h2 span {
padding-right: 6px;
background-color: #F9F9EE;
}
I've checked it in IE6 and Firefox, using it multiple times on the same page. :)
My favorite way to do this is:
<fieldset class="blah">
<legend>Heading</legend>
content...
</fieldset>
and then add
fieldset.blah {border-top: 1px solid #999;}
in your CSS. Hope that helps.
Try this:
h2 {
font-weight: normal;
border-bottom: 1px solid #DDD;
font-size: 1.6em;
height: 0.75em;
margin-bottom: 1.85em;
overflow: visible;
font-style: italic;
}
h2 span {
padding-right: 6px;
background-color: #F9F9EE;
}

Resources