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!
Related
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;
}
I have an issue with the line-height. Is there a way to reduce the line-height and move the i-elements closer so at least the petrol-background touch since it's not possible to use a negative value for line-height?
JS Fiddle
HTML:
<i>Nummer eins</i><br>
<i>Nummer zwei</i>
CSS:
#import url(http://fonts.googleapis.com/css?family=Lora:400,400italic,700,700italic);
i {
font-family: "Lora", serif;
font-size: 0.8em;
font-weight: normal;
line-height: 0em;
padding: 0px 3px;
color: white;
background-color: #406A76;
}
Thanks in advance!
check if this resolve your issue jsfiddle
html
<i>Nummer eins</i> // iremoved the br tag
<i>Nummer zwei</i>
css
i { // line height removed
font-family: "Lora", serif;
font-size: 0.8em;
font-weight: normal;
padding: 0px 3px;
color: white;
background-color: #406A76;
float: left; //added float left here
clear: both; //added clear both
}
If your goal is to eliminate the white bar between the two lines, it might be a good solution to put them both in a <div> or <span> (I used a span)
JSFiddle
html
<span>
<i>Nummer eins</i><br>
<i>Nummer zwei</i>
</span>
css
#import url(http://fonts.googleapis.com/css?family=Lora:400,400italic,700,700italic);
i {
font-family: "Lora", serif;
font-size: 0.8em;
font-weight: normal;
line-height: 0em;
padding: 0px 3px;
color: white;
background-color: #406A76;
}
span {
background-color: #406A76;
}
I have spent almost two hours trying to figure this out. Can anyone provide any insight into making the ::before selector work?
Relevant html:
<body><section><article><div>
<h2>What Others Have Said...</h2>
<div class="centered">
<h3 class="reviewExcerpt"><p>The services were awesome</p>
</h3>
<div class="5 floatRight">
<p>— Anonymous</p>
</div>
</div>
</div></article></section></body>
Relevant CSS:
.reviewExcerpt p::after {
content: "\00A0.\00A0.\00A0.";
}
.5 p::before {
content: "5 stars";
font-family: 'Font Awesome';
display:block;
}
.floatRight {
float: right;
display: block;
}
h3 {
font-family: 'Raleway', script, Helvetica, sans-serif;
font-size: 1.6em;
line-height: 1em;
margin: .8em 0 0;
font-weight: 600;
color: #555555;
}
h2 {
font-family: 'Raleway', script, Helvetica, sans-serif;
font-size: 1.9em;
margin: .8em 0 .25em;
font-weight: 600;
color: #b565a7;
}
.centered {
margin: 0 auto;
text-align: center;
}
JS fiddle: https://jsfiddle.net/k6y07r45/
The code shows ::after working just a couple lines up.
CSS Selectors (class [.] or ID [#]) cannot start with a number.
This SO question provides some insight on the required grammar if you want to explore it.
I updated your JS Fiddle, changing your class .5 to .a-5. You should also think about making your classes more semantic, to give you and anyone else reading your code clarity on complex projects. For instance, rating is a lot more meaningful than 5 (not to mention valid).
It's also worth noting right now that ::before and ::after can only select non-replaced elements. This doesn't affect what you're doing right now, but since you're experimenting that's another tidbit to remember.
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.
I have to make a input checkbox simple but could not find some kind of optional class at bootstrap, also searched on github some library and could not find anything simple as making foundation.
Thanks for help.
You can play with this to get a sense of what can be done:
#import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
#import url(//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css');
input[type="checkbox"] {
display: none;
}
.custom-check {
display: inline-block;
width: 25px; height: 25px;
background: white;
border: 1px solid #CCCCCC;
font-family: 'Glyphicons Halflings';
font-size: 22px;
line-height: 1;
}
.custom-check::before {
content: "\e013";
color: #424242;
display: none;
}
input[type=checkbox]:checked+.custom-check::before {
display: block;
color: white;
background-color: #554236;
}
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet">
<div>
<label >
<input type="checkbox">
<span class="custom-check"></span>
My Checkbox
</label>
</div>
If that's not enough, this answer to a similar question also gives a good overview of the css involved in customizing the bootstrap checkbox.
Just add an id(if it is just one checkbox) or class to that input element and define css for it:
CSS and HTML
'customId' would be the ID you give to the custom input tag:
<input id="customId" />
input#customId{
background: #888 !important;
border: none !important;
color: #000 !important;
}
jsut overwrite whatver styles you want to...
IMPORTANT: just add !important to the end of a style to force an override