Use all properties of Bootstrap's input error CSS - twitter-bootstrap-3

I'd like my input to appear the same as Bootstrap's styling for errors. What should this class extend from bootstrap to do this? Including the styling for :focus which is red glow rather than the default blue glow.
.ng-invalid.ng-touched.ng-dirty:not(form) {
// extend bootstrap style?
}
I've used .has-error, this will only work if there is an element further up the tree with the class .has-error which doesn't make sense to me. So this works:
.ng-invalid.ng-touched.ng-dirty:not(form) {
#extend .has-error;
}
HTML
<div class="form-group has-error">
..
<input type="text" class="form-control" required>
</div>
How can I get it to work by having just .has-error applied to the input without putting on the upper level element.

Actually, you can't. This class appears not only for input, but for labels too. That's why .has-error using with .form-group.
Same question as yours.
You can just create new class and add styles straight to your input:
.some-class:focus {
border-color: #843534;
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 6px #ce8483;
box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 6px #ce8483;
}
.some-class {
border-color: #a94442;
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
}

Related

How to apply style to buttons within div in a component?

I am trying to make a component with buttons inside a div, I am having issues, because the styles are not applying on the buttons, I guess I should not use slot here. Can someone guide me?
Component
<template>
<div :class="[$style.btnGroup]" v-bind="$attrs">
<slot :class="$style[variant]">/>
</div>
</template>
How I use this
<ButtonGroup variant="warning">
<button>Test</button>
<button>Test</button>
<button>Test</button>
</ButtonGroup>
I use css module
<style module>
.btnGroup button {
position: relative;
border: none;
font-weight: 400;
border-radius: 0.25rem;
cursor: pointer;
font-size: 1rem;
padding: 0.5rem 1rem;
transition: 0.1s;
}
.primary{
background: var(--primary-bg);
border: 1px solid var(--primary-bg);
color: white;
}
.warning {
background: var(--warning-bg);
border: 1px solid var(--warning-bg);
font-size: 1rem;
padding: 0.5rem 1rem;
transition: 0.1s;
color: black;
}
etc. for each variant I have different style.
You are applying the class on the button group not the buttons that are inside, to solve this instead of binding the class to the slot bind another variable and use that variable binding on each button or you can solve it through css thats why i suggested you show us the css give a class to the buttongroup the way you are doing and in css do as so:
<slot class="buttongroupclass">/>
.buttongroupclass button{
//the css you want to apply
}

header and need to extend underline because border-bottom not useful in my case

I would like to have an underline under my header, with the width of a bottom-border to put it simple.
However, I did not find how to extend the width/length of my underline.
Pay attention: in my case I cannot use a borderbottom. This solution does not work in my case.
<h1 id="hcomp"><img src="exp.png"/>Comp</h1>
The only solution would be to add spaces until i reach the width of my page:
<h1 id="hcomp"><img src="exp.png"/>Comp
</h1>
Solved.
<h1 id="hcomp"><img src="exp.png"/>Comp <hr class="hrstyle"></h1>
Css :
.hrstyle
{
border-top: 5px solid rgb(114, 159, 207);
margin-left: 0.6cm;
margin-top:0.05cm;
border-left: none;
border-right: none;
border-bottom: none;
}

Change the default color of materialize.css input fields. I have attached screenshot

I have tried to add custom css, but not worked. I need to change the color of text after selecting the input fields.
<div class="input-field form-group">
<input id="first_name" class="active validate form-control" name="first_name" type="text" value="">
<label for="first_name" class="mat-label">First Name</label>
</div>
An easier way, though you should edit the SCSS files.
But if you want in quick then use the following css.
I have used royalblue color here, you can use any hex color.
For bottom border
input:focus {
border-bottom: 1px solid royalblue !important;
box-shadow: 0 1px 0 0 royalblue !important;
}
For label color
label.active {
color: royalblue !important;
}
For the line color, I was able to change the default green to black with the css below.
input:not([type]):focus:not([readonly]), input[type="text"]:not(.browser-default):focus:not([readonly]), input[type="password"]:not(.browser-default):focus:not([readonly]), input[type="email"]:not(.browser-default):focus:not([readonly]), input[type="url"]:not(.browser-default):focus:not([readonly]), input[type="time"]:not(.browser-default):focus:not([readonly]), input[type="date"]:not(.browser-default):focus:not([readonly]), input[type="datetime"]:not(.browser-default):focus:not([readonly]), input[type="datetime-local"]:not(.browser-default):focus:not([readonly]), input[type="tel"]:not(.browser-default):focus:not([readonly]), input[type="number"]:not(.browser-default):focus:not([readonly]), input[type="search"]:not(.browser-default):focus:not([readonly]), textarea.materialize-textarea:focus:not([readonly]) {
border-bottom: 1px solid black;
-webkit-box-shadow: 0 1px 0 0 black;
box-shadow: 0 1px 0 0 black;
}
This green is actually $secondary-color
So in SASS, here is how it can be changed:
$secondary-color: #FEBD09;
#import "materialize-css/sass/components/variables";
When using Sass, you can change the color scheme of your site
extremely quickly.
To change the style of input/form you will only have to modify the variables under 10. Forms:
https://github.com/Dogfalo/materialize/blob/master/sass/components/_variables.scss
After changing the values, you need to build the new CSS file using SASS command line
Also check out: http://materializecss.com/sass.html, http://sass-lang.com/
You can change the text color easily by changing the code like
<div class="input-field form-group">
<input id="first_name" class="active validate form-control" name="first_name" type="text" value="">
<label for="first_name" class="mat-label">
<span class="black-text">First Name</span>
</label>
</div>
That is append -text to the color class. Check : http://materializecss.com/color.html
This is the CSS, you can change colors of materialize input animated text
input:not([type]):focus:not([readonly])+label,.form-wrap input[type=text]:not(.browser-default):focus:not([readonly])+label,.form-wrap input[type=password]:not(.browser-default):focus:not([readonly])+label,.form-wrap input[type=email]:not(.browser-default):focus:not([readonly])+label,.form-wrap input[type=url]:not(.browser-default):focus:not([readonly])+label,.form-wrap input[type=time]:not(.browser-default):focus:not([readonly])+label,.form-wrap input[type=date]:not(.browser-default):focus:not([readonly])+label,.form-wrap input[type=datetime]:not(.browser-default):focus:not([readonly])+label,.form-wrap input[type=datetime-local]:not(.browser-default):focus:not([readonly])+label,.form-wrap input[type=tel]:not(.browser-default):focus:not([readonly])+label,.form-wrap input[type=number]:not(.browser-default):focus:not([readonly])+label,.form-wrap input[type=search]:not(.browser-default):focus:not([readonly])+label,.form-wrap textarea.materialize-textarea:focus:not([readonly])+label{
color: #4285F4; /* after animation color change css */
}
.form-wrap input:focus:not([type]):not([readonly]),.form-wrap input[type="text"]:focus:not(.browser-default):not([readonly]),.form-wrap input[type="password"]:focus:not(.browser-default):not([readonly]), input[type="email"]:focus:not(.browser-default):not([readonly]),.form-wrap input[type="url"]:focus:not(.browser-default):not([readonly]), input[type="time"]:focus:not(.browser-default):not([readonly]),.form-wrap input[type="date"]:focus:not(.browser-default):not([readonly]), input[type="datetime"]:focus:not(.browser-default):not([readonly]),.form-wrap input[type="datetime-local"]:focus:not(.browser-default):not([readonly]), input[type="tel"]:focus:not(.browser-default):not([readonly]),.form-wrap input[type="number"]:focus:not(.browser-default):not([readonly]), input[type="search"]:focus:not(.browser-default):not([readonly]),.form-wrap textarea.materialize-textarea:focus:not([readonly]){
border-bottom: 1px solid #4285F4;
box-shadow: 0 1px 0 0 #4285F4; /* after animation color change css */
}

Twitter bootstrap 3 - text inputs in MVC razor view are hiding first couple charaters

I am using twitter bootstrap 3 with horizontal forms and form groups in my ASP.Net MVC razor app:
<form action="SomeAction" class="form-horizontal" method="post">
<div class="form-group">
<div class="col-lg-3 control-label">
#* label *#
</div>
<div class="col-lg-9">
#* textbox *#
#* validation *#
</div>
</div>
I also have the following in my layout template because every view will be a form and I don't want to have to style every control or view separately:
$('input[type=text]').addClass('form-control');
With text inputs, this is what I get:
The first 1-2 characters are hidden until I click in the control, which then shows them:
I am using IE 10. It doesn't happen in google chrome:
Not sure how to resolve this so any help is appreciated
I found out what was causing it. I have the following javascript in my _Layout.cshtml view:
$('input[type=text]').addClass('form-control');
Once I removed it and applied the class in the control it rendered properly:
#Html.TextBoxFor(model => model.Manufacturer, new { style = "width: 400px;", #maxlength="50", #class = "form-control" })
Text inputs seem to be the only one with this problem. textarea and select don't have the same behavior.
I wanted to avoid having to put the bootstrap class in every single control in every single view. If anyone knows of a better way please let me know.
Update
It turns out the padding style (12px) in the bootstrap.css (version 3.0.0, line 1712) is causing the problem:
.form-control {
display: block;
width: 100%;
height: 34px;
padding: 6px 12px; /* this line is causing the problem */
font-size: 14px;
line-height: 1.428571429;
color: #555555;
vertical-align: middle;
background-color: #ffffff;
border: 1px solid #cccccc;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-webkit-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
}
Hate to alter the bootstrap css. I am overriding it temporarily in my _Layout.cshtml view:
$('input[type=text]').addClass('form-control');
$('input[type=text]').css('padding', '6px 0');

Webkit: Image covers rounded border

When using a rounded border on an image, webkit browsers hide the border behind the image
CSS
img {
border: 10px solid #000;
border-radius: 100%;
}
HTML
<img src="http://25.media.tumblr.com/tumblr_mbjei3b3re1r30y2do1_500.jpg" />
Bug reproduced # http://jsfiddle.net/zPpVm/
This is probably related to this Webkit bug, but I cannot find a suitable work around.
A possible workaround is to use a box-shadow:
box-shadow: 0 0 0 10px black;
Live Example
The main problem: It won't be calculated in the box-model
As another workaround, you can wrap your image like this:
<span class="img_container" >
<img src="http://25.media.tumblr.com/tumblr_mbjei3b3re1r30y2do1_500.jpg" />
</span>
Than style elements:
.img_container {
border: 10px solid #000;
border-radius: 100%;
display: inline-block;
overflow: hidden;
}
.img_container img {
display: block;
}
All modern browsers except Opera will render it correctly.