Getting Semantic Grids scss foundation 4 to work - responsive-design

I have 3 sections that collapse under the default breakpoint
but I do not know how to get it to collapse with my own css using scss.
default foundation grid that works well and collapses
<div class="row">
<div class="large-4 columns">...</div>
<div class="large-4 columns">...</div>
<div class="large-4 columns">...</div>
</div>
I tried below out but but it doesn't seem to collapse
<div class="container">
<div class="div1">...</div>
<div class="div2">...</div>
<div class="div3">...</div>
</div>
.container{
#include grid-row;
.div1 {
#include grid-column(4);
}
.div2 {
#include grid-column(4);
}
.div3 {
#include grid-column(4);
}
}

its because you are writing the SCSS for grid-row wrong.
#include grid-row();
Do NOT use #extend. that is NOT how foundation4 is made to be used... #extend just stuffs your styles into .row and .column and that is not what you want to do, instead you want to stick THOSE styles into your styles the reverse way using semantic code therefore you can change the code later in your SCSS and it updates later.
Here is the correct answer:
HTML
<div class="container">
<div class="div1">...</div>
<div class="div2">...</div>
<div class="div3">...</div>
</div>
SCSS
.container{
#include grid-row();
.div1, .div2, .div3 {
#include grid-column(12);
#media #{$medium-up} {
#include grid-column(4);
}
#media #{$large-up} {
#include grid-column(4);
}
}
}
Note: this is with foundation 5. You must create breakpoints. Your mobile breakpoint should have 12 columns if you want the whole view to collapse in mobile, or whatever you want. This is the same as
<div class="small-12 columns"> </div>
if you want 4 columns for medium and up you write:
<div class="small-12 medium-4 columns"> </div>
So to write that symantically without helper classes you write this:
<div class="myclassname"> </div>
and the SCSS code is:
.myclassname {
#include grid-column(12);
#media #{$medium-up} {
#include grid-column(4);
}
}

I was baffled by this, but then found out it is actually intended behavior. Here's a quote from the official Foundation grid documentation:
We kept media queries out of the code for our grid mixins. This will enable you to include the mixins inside of whatever breakpoint you'd like, putting you in complete control. If you want to create 10 breakpoints and shift the layout around between each one, by all means. If you want to use only the default breakpoints, we've got variables for that.

Use #extend instead.
.container{
#extend .grid;
div{
#extend .columns;
}
}
.div1 {
#extend .large-4;
}
.div2 {
#extend .large-4;
}
.div3 {
#extend .large-4;
}
I made a couple of mixins that works well and I think that makes it easier:
https://gist.github.com/jofralogo/5324278

Related

Semantic React UI : is there a way to change the background color of a checkbox toggle?

I'm using toggle checkboxes by Semantic React UI.
The background color of a checkbox is defined in their styles here :
.ui.toggle.checkbox input:checked~.box:before, .ui.toggle.checkbox input:checked~label:before {
background-color: #2185d0!important;
}
... But I would like to be able to set a prop that would change that color, like
<Checkbox toggle toggleColor="red"/>
Could I extend that component to achieve that, or is there another way to achieve this ?
Thanks !
Yes you can, but it is not pretty!
I have a solution that works with semantic-ui and is heavily tested. I assume that it also works with semantic-ui-react but did not test extensively.
First, a color feature for checkboxes is missing from semantic-ui (as far as I can see, there is no documentation about it at least). So you need to use CSS to define your colors. All your colors! So if you have a lot you might to want SASS or something. Also you might want to make a feature request with semantic-ui.
Second, my solution uses the label of the checkbox to color the checkbox. I am fully aware that this is not pretty but this is apparently the only way to do this without too much additional code or even more ugly methods.
Add this to your code (please note, stackoverflow does not render this example properly since the <link rel="stylesheet" href="../semantic_ui/dist/semantic.min.css">is obviously missing. If there is a way to add this on this side please let me know.)
.ui.toggle.checkbox input:focus:checked ~ .box:before,
.ui.toggle.checkbox input:focus:checked ~ .coloring.black:before,
.ui.toggle.checkbox input:checked ~ .box:before,
.ui.toggle.checkbox input:checked ~ .coloring.black:before {
background: #000000 !important;
}
.ui.toggle.checkbox input:focus:checked ~ .coloring.white:before,
.ui.toggle.checkbox input:checked ~ .coloring.white:before {
background: #FFFFFF !important;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/semantic-ui#2.4.2/dist/semantic.min.js"></script>
<div class="ui segment">
<div class="ui attached icon form" id="info_input_form">
<div class="ui toggle checkbox">
<input type="checkbox" tabindex="0">
<label class="coloring black">Toggle</label>
</div>
</div>
</div>

AngularJS : How do i override directive's style in my view?

I am calling error-stuff directive in my view as below and i am trying to override the directive's padding 15px to 0px in my view which is not working. So my div1's value and div2's values are not in a straight line since div2 takes more padding in my view.
Error:
Oops !!! Its look like something going wrong !!! Please try again later ...
<div id="div1" class="row">
<div class="pull-left">
<span>Error :</span>
</div>
<div id="div2" style="padding:0px; vertical-align:top">
<error-stuff></error-stuff>
</div>
</div>
The html template on the error-stuff directive as below
<div class="error-class">
<span>Oops !!! Its look like something going wrong !!! Please try again later
... </span>
</div>
in my app.css
.error-class
{
margin-bottom:20px;
padding:15px;
box-sizing:border-box;
line-height:1.5;
font-size:15px;
}
So how do i make div1 and div2 content in straight line by overriding the directives padding:15px to padding:0px?
Assuming error-stuff is used somewhere else and you can't change the global css, in this case you can use a targeted override by specifying the parent in css
#div2 .error-class {
padding: 0;
}

Layout structure - card layout and toolbar with angularjs md

How can I with use of AngularJS Material Design lib achieve page structure such as described in the official Layout structure guideline and exemplified in the screenshot below? I want to have centralised card breaking the edges of the page toolbar. Codepen example would be highly appreciated.
Edit: related thread: Angular Material Design layout
I figured I'd post this to help others trying to do the same thing with Materialize CSS. You can change the height of the nav-bar, and the size/placement of card.
Demo
HTML
<nav>
<div class="nav-wrapper">
<i class="material-icons">list</i>
</div>
<div class="nav-wrapper">
</div>
</nav>
<
<<div class="row" id="card-placement"> <!-- id added here -->
<div class="col s12 m8 offset-m2">
<div class="card grey lighten-5">
<div class="card-content grey-text text-darken-1">
<h5 class="head">Title</h5> <!-- class added here -->
<div class="divider"></div>
<p>Stuff goes here</p>
</div>
</div>
</div>
</div>
CSS
/* Moves card up into navbar */
#card-placement{
margin-top:-60px
}
/* Moves Title position up to be level with nav bottom */
.head {
margin-top: -2px;
}
nav {
color: #fff;
background-color: #ee6e73;
width: 100%;
height: 112px;
line-height: 56px;
}
.nav-wrapper {
margin-left: 20px;
}
You can easily do this with a little CSS
.card_position{
margin-top:-70px
}
Add this class to the card element.

How do I hide a div on mobile

I have the following landing page - Cold Call with Confidence
There are two downward facing arrows on the page that are generated with the code below:
<div class="content" style="padding-top:0px;">
<div class="right sld_cont">
<img src="http://coldcallwithconfidence.com/wp-content/uploads/2015/01/Arrow_comic_right_gray_T.png">
</div>
<div class="left sld_cont">
<img src="http://coldcallwithconfidence.com/wp-content/uploads/2015/01/Arrow_comic_right_gray_T1.png">
</div>
</div>
I would like to hide one of the arrows on mobile as it looks repetitive in the mobile view.
Can anyone explain how I might do that?
I would suggest that you are looking to hide the right arrow on viewports that stack those elements rather than specifically hiding them on mobile devices.
The previous answer is correct based upon your question, however I think this might be a more suitable solution for you.
#media only screen and (max-width: 679px) {
.right.sld_cont {
display: none;
}
}
This means that for any viewport that is 679px or smaller the right arrow will be hidden.
Take a look at MobileDetect.js , then you can use this as a PHP if statement, and only show it if it's not a mobile device.
if(!$detect->isMobile()) {
# desktop code
}
Edit:
<?php if(!$detect->isMobile()) { ?>
<div class="content" style="padding-top:0px;">
<div class="right sld_cont">
<img src="http://coldcallwithconfidence.com/wp-content/uploads/2015/01/Arrow_comic_right_gray_T.png">
</div>
<div class="left sld_cont">
<img src="http://coldcallwithconfidence.com/wp-content/uploads/2015/01/Arrow_comic_right_gray_T1.png">
</div>
</div>
<?php } ?>

Add class to accordion heading using AngularJS ui-bootstrap?

I want use ng-class to conditionally add a class to the accordion-heading, but it appears that not even setting a class explicitly on the element gets preserved. I have this:
<div accordion close-others="true">
<div ng-repeat="currItem in items" accordion-group>
<div accordion-heading class="myClass">My Heading {{$index}}</div>
<div class="accordion-inner myClass">asdf asdf asdf</div>
</div>
</div>
And the fiddle: http://jsfiddle.net/Zmhx5/1/
When I inspect the accordion heading element, the class myClass is nowhere to be found. Is there some reason I can't add classes to the accordion heading?
You can put the CSS inside the directive accordion-heading tags:
<accordion-heading>
<div class="myClass">My Heading {{$index}}</div>
</accordion-heading>
In Angular UI Bootstrap, they have created a directive for accordion-heading. Template for this is written in ui-bootstrap-tpls.js. Try to modify directive for accordion-heading.
I ran into the same issue trying to conditionally apply a background color to the heading with ng-class. This is a bit of a workaround, but it does the trick.
First we need to remove the padding from the heading. If you inspect it, you'll see that it generates a div with a .panel-heading class and a padding: 10px 15px (see note below). The padding is what causes issues when trying to apply a background to a nested div, so lets remove it.
.panel-heading {
padding: 0;
}
Now we can add our nested div and give it the same padding to get back our previous look.
<accordion-heading>
<div class="myClass" style="padding: 10px 15px">My Heading {{$index}} </div>
</accordion-heading>
Here's the updated jsfiddle
Note my code above is from a different version of ui-bootstrap. The classes were slightly different in this jsfiddle, so you will see a slightly different solution. The concept, however, is the same.
you could just apply your CSS to an outer div like this:
HTML:
<div ng-app="myApp" ng-controller="MyCtrl">
<div accordion close-others="true">
<div class="myClass" ng-repeat="currItem in items" accordion-group>
<div accordion-heading>
<div>My Heading {{$index}}</div>
</div>
<div class="accordion-inner">asdf asdf asdf</div>
</div>
</div>
</div>
CSS:
.myClass {
background-color: gray;
color: black;
}
.accordion-inner {
background-color: green;
color: black;
}
JS:
angular.module("myApp", ['ui.bootstrap'])
.controller("MyCtrl", function ($scope) {
$scope.items = [{}, {}, {}, {}];
});
then, change it to use ng-class and it should work just fine
pd: (Sorry about the bad english)

Resources