Foudation grid system not working on Angular Form - css

I have done the intsallation of foundation 6 on my Angular and it works fine but I realized the grid system is not working at all. I have made a lot of tweaks and turns but still no luck. Anyone knows why this may be. Thank you.
<div>
<h3>
Add A Warehouse
</h3>
</div>
<form novalidate [formGroup]= "warehouseForm" (ngSubmit)="onSubmitForm()">
<div class="row">
<div class="medium-6 columns">
<label>Warehouse Name
<span>
<i class="fa fa-user"></i>
</span>
<input type="text" placeholder="Warehouse Name">
</label>
</div>
<div class="medium-6 columns">
<label>Warehouse Country
<span>
<i class="fa fa-user"></i>
</span>
<input type="text" placeholder="Warehouse Country">
</label>
</div>
</div>
<div class="row">
<div class="medium-6 columns">
<label>Warehouse Region
<span>
<i class="fa fa-user"></i>
</span>
<input type="text" placeholder="Warehouse Region">
</label>
</div>
<div class="medium-6 columns">
<label>Warehouse City
<span>
<i class="fa fa-user"></i>
</span>
<input type="text" placeholder="Warehouse City">
</label>
</div>
</div>
<div class="row">
<div class="medium-6 columns">
<label>Warehouse Address
<span>
<i class="fa fa-user"></i>
</span>
<input type="text" placeholder="Warehouse Address">
</label>
</div>
<div class="medium-6 columns">
<label>Warehouse Street
<span>
<i class="fa fa-user"></i>
</span>
<input type="text" placeholder="Warehouse Street">
</label>
</div>
</div>
<div class="row">
<div class="medium-6 columns end">
<label>Warehouse Keeper
<span>
<i class="fa fa-user"></i>
</span>
<input type="text" placeholder="Warehouse Keeper">
</label>
</div>
</div>
<div>
<button type="submit" class="success button expanded">Save</button>
</div>
</form>
This is my form , I can say I say my foundation works because the fonts and other things are working. But the grid is just not working.
In the .angular-cli.json
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"../node_modules/foundation-sites/dist/css/foundation.css",
"../node_modules/font-awesome/css/font-awesome.css",
"styles.css"
],
"scripts": [
"../node_modules/foundation-sites/vendor/jquery/dist/jquery.js",
"../node_modules/foundation-sites/dist/js/foundation.js"
],
Image from code inspection

I think the issue is with the version of foundation you've got!
Check what grid system your current install of Foundation is using because the newest version of Foundation comes with their XY Grid enabled when you download the complete package and this wont call the CSS of the old grid!
You'll need to re-download a custom version of Foundation but check 'float grid' when you're downloading it and it will get you back to the older grid system and your code should work!
Heres a link to download the custom foundation version:
https://foundation.zurb.com/sites/download/
And if you want to learn more about the new XY Grid heres a link: http://foundation.zurb.com/sites/docs/xy-grid.html
Hope this helps!

In case anyone else has an issue with using Foundation Flex Grid:
Try adding these in your styles.scss:(you could read more from here)
#import "../node_modules/foundation-sites/assets/foundation";
#include foundation-flex-classes;
#include foundation-flex-grid;
If that did work, here's how I add foundation to my Angular 8 project:
Install foundation sites and jQuery:
$ npm install --save foundation-sites jquery
Add these in angular.json file:
"styles": [
"src/styles.scss",
"node_modules/foundation-sites/dist/css/foundation.min.css"
],
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/foundation-sites/dist/js/foundation.min.js"
],
Add $ and foundation in app.component.ts
-
import { Component } from '#angular/core';
declare var $: any; // <=========== Add this
#Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = 'app-frontend';
ngOnInit(): void {
$(document).foundation(); // <=========== Add this
}
}
Ctrl C and npm start or ng serve again to reset the server.

Related

Primeng angular 7 - css is not getting applied

I am using angular 7 and primeng library for UI compnents. CSS is not getting applied to the HTML elements. I have imported these css files in angular.json:
"styles": [
"node_modules/font-awesome/css/font-awesome.min.css",
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"node_modules/primeicons/primeicons.css",
"node_modules/primeng/resources/themes/nova-light/theme.css",
"node_modules/primeng/resources/primeng.min.css",
"src/styles.scss"
]
On the demo page: http://primefaces.org/primeng/#/inputgroup
Input box have these classes generated: ui-inputtext ui-corner-all ui-state-default ui-widget
These are missing from my generated html, if i apply these classes manually css gets applied. This is HTML code:
<h3 class="first">Addons</h3>
<div class="ui-g ui-fluid">
<div class="ui-g-12 ui-md-4">
<div class="ui-inputgroup">
<span class="ui-inputgroup-addon"><i class="pi pi-user" style="line-height: 1.25;"></i></span>
<input type="text" pInputText placeholder="Username">
</div>
</div>
<div class="ui-g-12 ui-md-4">
<div class="ui-inputgroup">
<span class="ui-inputgroup-addon">$</span>
<input type="text" pInputText placeholder="Price">
<span class="ui-inputgroup-addon">.00</span>
</div>
</div>
<div class="ui-g-12 ui-md-4">
<div class="ui-inputgroup">
<span class="ui-inputgroup-addon">www</span>
<input type="text" pInputText placeholder="Website">
</div>
</div>
</div>
I have tried ViewEncapsulation:
import { ViewEncapsulation } from '#angular/core';
#Component({
..
encapsulation: ViewEncapsulation.None
})
There is no change in app.module.ts for primeng.
As Per My Example You need to change in app.module.ts file
See below Images
You need to import InputTextModule from primeng in root module of your component
And here is the angular.json file
if you find this helpfull...
I had the same problem, then I tried to put the css files into my styles.css instead of angular.json and it works fine now
change this...(angular.json)
"styles": [
"src/styles.scss",
"node_modules/primeicons/primeicons.css",
"node_modules/primeng/resources/themes/saga-blue/theme.css",
"node_modules/primeng/resources/primeng.min.css"
],
by this...(src/styles.scss):
#import '~primeng/resources/primeng.min.css';
#import '~primeng/resources/themes/bootstrap4-light-blue/theme.css';
#import '~primeicons/primeicons.css';
When you install primeng-lts
Add to below styles to angular.json
"styles": [
"./node_modules/primeng-lts/resources/themes/nova-light/theme.css",
"./node_modules/primeng-lts/resources/primeng.min.css",
"node_modules/primeicons/primeicons.css"
],

Bootstrap 4 invalid feedback with input group not displaying

I have been looking into Bootstrap 4 - beta, however when using .is-invalid with .input-group it doesn't seem to show up.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet" />
<div class="form-group">
<label for="label">Label</label>
<div class="input-group">
<div class="input-group-addon">
label
</div>
<input type="text" value="" name="label" class="form-control is-invalid">
</div>
<div class="invalid-feedback is-invalid">
<strong>Invalid Label</strong>
</div>
</div>
How are you meant to display an invalid message while using .input-group?
Adding the following CSS works as a workaround, but it seems odd.
.form-group.is-invalid {
.invalid-feedback {
display: block;
}
}
Boostrap 4 is very buggy. My suggestion is to replace:
<div class="invalid-feedback">
Text here
</div>
With:
<div class="text-danger">
Text here
</div>
And the second one looks virtually the same and will not fail.
For a better look, try:
<div class="text-danger">
<small>Text here</small>
</div>
They haven't taken into account their own examples using input group addons and buttons, even with a column model. The markup does only facilitate "neighboring" elements, not parent > neighboring element (there is no CSS rule for that).
It seems, for now, you should fall back to Alpha 6 or program your own CSS classes accordingly. I've done the same, unfortunately.
Please note when reading my answer that this was posted just as the beta was released. :)
I solved it by adding d-block class:
#error('terms')
<div class="invalid-feedback d-block" role="alert">
<strong>{{ $message }}</strong>
</div>
#enderror
Happy coding!
Bootstrap docs here about d-block:Display property
The way Bootstrap does override the display from none to block is by checking first for a previous is-invalid class, for example! Check this CSS out:
That means, in case of an error, first is-invalid must be applied on an element and then invalid-feedback on another afterward! Like the following in Laravel, for instance:
{{-- Either following an input --}}
<input type="password" id="registerPassword"
class="form-control #error('register_password') is-invalid #enderror"
name="register_password" required autocomplete="new-password"
>
#error('register_password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
{{-- Or separately in DOM --}}
#error('register_password')
<div class="is-invalid">...</div>
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
Working example with a trick using flex-wrap and w-100:
<div class="form-group">
<label class="form-control-label">Name</label>
<div class="input-group flex-wrap">
<span class="input-group-addon"><span class="fa fa-lock"></span></span>
<input name="name" class="form-control is-invalid" type="text">
<div class="invalid-feedback w-100">Custom error</div>
</div>
</div>
Add .is-invalid to the .input-group.
If the invalid-feedback element is preceded by an element with .is-invalid it will be displayed -- that is how server-side validation is supported.
I found this solution
<div class="input-group ">
<div class="input-group-prepend">
<div class="input-group-text">Start Date</div>
</div>
<input type="text" class="form-control is-invalid" placeholder="Date Input">
<div class="invalid-feedback order-last ">
Error Message
</div>
<div class="input-group-append">
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
</div>
</div>
Inspecting the .invalid-feedback class I've found this definition (bootstrap 4.3)
.invalid-feedback {
/*display: none;*/
width: 100%;
margin-top: .25rem;
font-size: 80%;
color: #dc3545;
}
You could copy and rename this class and use it without the built-in limitations
here is my "diy" answer
html
<div class="container">
<div class="row p-3">
<div class="col-md-6 mb-3">
<label class="sr-only">End Date/Time</label>
<div class="input-group">
<div class="input-group-prepend ">
<div class="input-group-text error-feedback">Start Date</div>
</div>
<input type="text" class="form-control error-feedback" placeholder="Date Input">
<div class="invalid-feedback order-last ">
Error Message
</div>
<div class="input-group-append error-feedback">
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
</div>
</div>
</div>
</div>
css
.error-feedback{
border:1px red solid;
}
I know there is a bit off but, IMO pretty good compared this example
<div class="form-group">
<label class="form-control-label">Name</label>
<div class="input-group flex-wrap">
<span class="input-group-addon"><span class="fa fa-lock"></span></span>
<input name="name" class="form-control is-invalid" type="text">
<div class="invalid-feedback d-block">Custom error</div>
</div>
Alternatively you can add the .is-valid/.is-invalid class to the parent element .input-group. Then you can change the css to add the red border to the child elements like this:
.input-group.is-invalid .form-control,
.input-group.is-invalid .custom-select {
border-color: #FA5252;
}
.input-group.is-invalid .input-group-prepend .input-group-text {
border: 1px solid #FA5252;
}
.input-group.is-valid .form-control,
.input-group.is-valid .custom-select {
border-color: #05A677;
}
.input-group.is-valid .input-group-prepend .input-group-text {
border: 1px solid #05A677;
}
I'm using Bootstrap 4.3 and following code worked for me. Try adding "validated" class with "form-group" and group error message inside the input-group.
<div class="form-group validated">
<label class="form-control-label">Name</label>
<div class="input-group">
<span class="input-group-addon"><span class="fa fa-lock"></span></span>
<input name="name" class="form-control is-invalid" type="text">
<div class="invalid-feedback">Custom error</div>
</div>
</div>
In my app, I'm namespacing Bootstrap's styles so that they don't pollute the styles outside my app:
.my-app {
#import '~bootstrap/scss/bootstrap.scss';
}
What I found by looking through the generated styles is that the validation css ultimately gets clobbered due to the mixin that generates it into:
.was-validated .my-app:invalid ~ .invalid-feedback,
.was-validated .my-app:invalid ~ .invalid-tooltip,
.my-app.is-invalid ~ .invalid-feedback,
.my-app.is-invalid ~ .invalid-tooltip {
display: block;
}
Note that it's .my-app.is-invalid and not .my-app .is-invalid. It looks like this is a consequence of the form-validation-state-selector mixin that generates it, which has a comment suggesting it's the result of a dart-sass compatibility fix. One hack I could do is add the my-app class to every input that needed validation but that's not ideal.
I was able to resolve it by extending my namespace selector with a wildcard as follows:
.my-app * {
#import '~bootstrap/scss/bootstrap.scss';
}

ASP Styling isn't working properly

I'm working on an ASP site for the company I work at. It's about adding money saving or earning activities to an overview that one of the directors can look at.
Currently though I have some styling issues, using bootstrap here.
I believe I used to have this issue once but how I solved it escapes me. I can't center all the elements and I can't make the input boxes connect with the addons on the right side as is seen in the picture.
<div class="container body-content" style="padding-top: 15px;">
<div class="container" align="center">
<div class="col-lg-8">
<div class="row">
<h2>Abstract</h2>
<div class="form-group">
<div class="input-group" style="padding-bottom: 10px;">
<span id="add-addon-styling" class="input-group-addon">FYE</span>
<select class="form-control required" id="new-activity-fye-dropdown">
<option value="1">On Track</option>
<option value="2">Issue</option>
<option value="3">Behind</option>
</select>
<span class="input-group-addon" data-toggle="tooltip" data-placement="top" title="The Full Year Expectation of the Activity. Usually On Track on creation.">
<b>?</b>
</span>
</div>
<div class="input-group" style="padding-bottom: 10px;">
<span id="add-addon-styling" class="input-group-addon">Activity Name</span>
<input type="text" class="form-control required" id="new-activity-modal-name-field"
aria-describedby="new-activity-modal-name-field" />
<span class="input-group-addon" data-toggle="tooltip" data-placement="top"
title="The Name of the Activity. This name appears in the Activity Overview.">
<b>?</b>
</span>
</div>
<div class="input-group" style="padding-bottom: 10px;">
<span id="add-addon-styling" class="input-group-addon">Responsible</span>
<input type="text" class="form-control required" id="new-activity-modal-responsible-field"
aria-describedby="new-activity-modal-responsible-field" disabled />
<span class="input-group-addon" data-toggle="tooltip" data-placement="top"
title="The responsible person for this activity. This it the go-to person for questions, progress and reports.">
<b>?</b>
</span>
</div>
<!-- TODO: Find an automatic way to make this dropdown -->
<div class="input-group" style="padding-bottom: 10px;">
<span id="add-addon-styling" class="input-group-addon">Department</span>
<select class="form-control required" id="new-activity-modal-department-dropdown">
<!-- Handled in content-controller: CreateNewActivityDepartmentDropdown() -->
</select>
<span class="input-group-addon" data-toggle="tooltip" data-placement="top"
title="The department this activity belongs to.">
<b>?</b>
</span>
</div>
<div class="input-group" style="padding-bottom: 10px;">
<span id="add-addon-styling" class="input-group-addon">Start Time</span>
<input class="form-control" type="text" id="new-activity-modal-datepicker-start" />
<span class="input-group-addon" data-toggle="tooltip" data-placement="top"
title="The start of the activity. Usually today's date.">
<b>?</b>
</span>
</div>
<div class="input-group" style="padding-bottom: 10px;">
<span id="add-addon-styling" class="input-group-addon">End Time</span>
<input class="form-control" type="text" id="new-activity-modal-datepicker-end" />
<span class="input-group-addon" data-toggle="tooltip" data-placement="top"
title="The estimated end of the activity.">
<b>?</b>
</span>
</div>
</div>
</div>
<div class="row">
<h2>Description</h2>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">Upload a thorough description explaining the Activity.</span>
</div>
</div>
</div>
<div class="row">
<h2>Estimation</h2>
<div class="form-group">
<div class="input-group" style="padding-bottom: 10px;">
<span id="add-addon-styling" class="input-group-addon">AX Account Number(s)</span>
<input type="text" class="form-control required" id="new-activity-modal-ax-account-numbers-field"
aria-describedby="new-activity-modal-ax-account-numbers-field" />
<span class="input-group-addon" data-toggle="tooltip" data-placement="top"
title="AX Account number associated with the activity.
Multiple accounts can be added separated by commas.">
<b>?</b>
</span>
</div>
<div class="input-group">
<span class="input-group-addon">Upload the estimation calculations for the Activity.</span>
</div>
</div>
</div>
</div>
</div>
</div>
I feel that my HTML is fairly normal but I have a hard time applying styles from CSS files in ASP in the first place.
How would I make the addons on the right side connect with the input fields?
UPDATE
It appears that the problem was inside a default generated file called Site.css. It had the following in it:
input,
select,
textarea {
max-width: 280px;
}
Commenting that out solves the problem.
Since I don't know how exactly ASP's css structure is, here is how i would approach this situation:
use your browser's inspector to check exactly what type of css rule is making the "?" button be all the way to the right, i can only assume it either has a float, or the form has a huge margin on it's right.
once you have found the issue, you could use your browser's inspector further to test out some edits, if it's a margin thing, see how much margin it will actually need, if it's a float issue, see how it will look with float:none
as soon as you've found the solution to the issue, you will need to apply it, to do this add a custom .css file AFTER ASPs css files, this way whatever you write in it will overwrite any existing rules.
add the fixes to this new file and you should be done.
There must be something elsewhere on the page that is breaking the style of the select boxes, because when I view your snippet in codepen, in both Chrome and IE11, the select boxes do stretch to the question mark boxes at the right:
codepen.io/anon/pen/pgVoQg
btw, inline styles should usually be avoided where possible

.field_with_errors in Rails breaks Twitter Bootstrap 3 input styles with addons

I have HAML
...
.row
.col-md-3.form-group
= offer.label :departure_date, "Abfahrt"
.input-group.date
= offer.text_field :departure_date, class: "form-control", readonly: ""
%span.input-group-addon
%i.glyphicon.glyphicon-calendar
...
that generates such HTML (datepicker markup)
<div class="row">
<div class="col-md-3 form-group">
<label for="offer_departure_date">Abfahrt</label>
<div class="input-group date">
<input class="form-control" readonly="readonly" type="text" name="offer[departure_date]" id="offer_departure_date">
<span class="input-group-addon">
<i class="glyphicon glyphicon-calendar"></i>
</span>
</div>
</div>
</div>
When I get error, Rails wraps label and input with a div having class field_with_errors.
<div class="row">
<div class="col-md-3 form-group">
<div class="field_with_errors"><label for="offer_departure_date">Abfahrt</label></div>
<div class="input-group date">
<div class="field_with_errors"><input class="form-control" readonly="readonly" type="text" value="" name="offer[departure_date]" id="offer_departure_date"></div>
<span class="input-group-addon">
<i class="glyphicon glyphicon-calendar"></i>
</span>
</div>
</div>
</div>
In my application.css.sass I've extended field_with_errors with the following:
.field_with_errors
#extend .has-error
After that most simple fields became normal styling accept of this datepicker: the input field lost its rounded corners, addon part remained default (even not red). In combination with other fields this looks ugly. How can that be fixed? Here is screenshot with this field - http://minus.com/lbeNYx1yXyqk4C
Use the following css to fix the issue
.field_with_errors {
display: block !important;
}
.field_with_errors > .datetimepicker {
display: none !important;
}

Bootstrap Button

I want this button to be aligned horizontally, i'm using bootstrap.min.js v3.0.0, bootstrap.min.css, application.css.
<div class="row">
<div class="col-lg-4 col-md-3 col-sm-4 col-xs-6 form-group">
<label>Fecha desde</label>
<div class="input-group date datepicker" >
<input class="form-control col-md-12" type="text">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
<div class="col-lg-4 col-md-3 col-sm-4 col-xs-6 form-group">
<label>Fecha cierre</label>
<div class="input-group date datepicker">
<input class="col-md-12 form-control" type="text" />
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
<div class="col-lg-4 col-md-6 col-sm-4 col-xs-12">
<input type="button" class="btn btn-success" style="alignment-adjust:central;" value="Buscar" onclick="cargarLista();"/>
</div>
I have:
I want:
I really appreciate any help you can provide!
Bootstrap is only a framework to help you get started, there are times that you would need to add or override from it's base code.
This is one of those times.
How to proceed:
you have wrapping the button a <div> add a class to that div called align-bottom.
then, create a file called application.css (if you don't have it yet) in the same place as your CSS files and remember to place that <link> below the bootstrap calls
for example:
<link href="/assets/css/bootstrap.min.css" rel="stylesheet" />
<link href="/assets/css/application.css" rel="stylesheet" />
and inside that application.css write the style:
.controls.align-bottom {
line-height: 90px;
}
Note that you could need to change the 90px up or down in order to make it correctly.
demo in JsBin: http://jsbin.com/vajut/2/edit?html,css,output
This is one of the ways... there are others, CSS is a really big and lovely thing!
Looks like you used <legend> on your text inputs.
Easy fix would be to add:
<legend> </legend>
To your button input

Resources