I have a small question about #content in sass
I still not understand well how to use it, like I did read content is if you want use a mixin and insert something else there.
My question is: why I need use #content if works whithout?
my example:
#mixin context--alternate-template {
margin: 0;
font-size: 14px;
}
.content-sample {
#import context--alternate-template;
background-color: black;
}
output css:
.content-sample {
margin: 0;
font-size: 14px;
background-color: black;
}
sample I a saw on web:
#mixin context--alternate-template {
margin: 0;
font-size: 14px;
#content
}
.content-sample {
#import context--alternate-template;
background-color: black;
}
output css:
.content-sample {
margin: 0;
font-size: 14px;
background-color: black;
}
so yes why I need insert #content in the mixin if works whithout.
#content is useful for injecting a copy of rules inside your mixin. The correct syntax of your sample seen on the web becomes:
SCSS:
#mixin context--alternate-template {
margin: 0;
font-size: 14px;
#content
}
.content-sample {
#include context--alternate-template {
background-color: black;
}
}
Note:- The brackets after the #include call. Now, you have the rule background-color: black; injected after font-size: 14px;.
CSS output:
.content-sample {
margin: 0;
font-size: 14px;
background-color: black;
}
In this case, #content is useless. In fact, the most interesting usage with #content is to inject nested selectors:
SCSS:
#mixin context--alternate-template {
margin: 0;
font-size: 14px;
#content
}
.content-sample {
#include context--alternate-template {
.important-thing {
color: red;
}
&.is-italic {
font-family: 'my-webfont-italic';
}
}
// outside mixin call
background-color: black;
}
CSS output:
.content-sample {
margin: 0;
font-size: 14px;
background-color: black;
}
.content-sample .important-thing {
color: red;
}
.content-sample.is-italic {
font-family: 'my-webfont-italic';
}
One more use case of #content that helped me to see its value - media queries
SCSS:
#mixin desktop {
#media screen and (min-width: $desktop-size) {
#content;
}
}
.main {
display: flex;
flex-direction: row;
#include desktop{
flex-direction: column;
}
}
CSS output
.main {
display: flex;
flex-direction: row;
}
#media screen and (min-width: 60rem) {
.main {
flex-direction: column;
}
}
Related
I googled everything by now and tried everything including img-fluid, did not work, I can't seem to figure out how to make the image responsive (pretty much a beginner lol), if I resize the browser window the image stays the same size, does not scale.
The logo image size that am trying to keep is 734px x 132px
Edit: I have already tried auto height and still doesn't work
.navbar-brand {
color: $primary;
padding: 0;
img {
max-width: 100%;
height: 132px;
max-height: 132px;
#include media-breakpoint-down(md) {
max-height: 132x;
}
}
}
#include media-breakpoint-up(md) {
.header-navbar-top-right-search {
margin-left: auto;
}
}
#include media-breakpoint-up(lg) {
.header-navbar-top-left {
max-width: 42%;
flex: 0 0 42%;
}
.header-navbar-top-center {
max-width: 16%;
flex: 0 0 16%;
}
.header-navbar-top-right-search {
flex: 0 0 auto;
}
.header-navbar-top-right {
flex: 0 0 auto;
}
}
.header-top-line {
background-color: $section-bg;
a:not(.edit-link) {
padding: 22px $spacer 20px;
font-size: 0.8125rem;
line-height: 1.125rem;
}
.login-list > .nav-item a {
font-weight: 700;
}
}
.header-bottom-line {
background-color: $white;
}
.header-quantity-box {
margin-left: $spacer * 0.25;
}
.nav-link,
.search-module .btn,
.header-navbar a {
color: $white;
&:active,
&:hover {
color: $primary;
}
}
Give it some width and put the height as auto.
img{
width: 100%;
height: auto;
}
Update 1
Now see, You can update max-width as your need
Snippet
.navbar-brand {
color: blue;
padding: 0;
}
.navbar-brand img {
max-width: 734px;
height: auto;
width:30%;
margin: auto;
}
#media only screen and(max-width: 768px){
.navbar-brand img{
width: 40%;
}
}
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<a class="navbar-brand" href="#">
<img src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_160x56dp.png" title="borhykerteszetcsomagküldés" alt="borhykerteszetcsomagküldés"></a>
Did this help you 🤨?
First of all, this material datepicker is based on: https://stackblitz.com/angular/qmnrlgabjly?file=src%2Fapp%2Fdatepicker-views-selection-example.ts
I have copied all the code i need from: https://material.angular.io/components/datepicker/overview
however the popup for choosing year and date is always positioned wrong (see picture under):
I have the exact same code as the example, and my scss-file looks like this:
#import "../../../shared/styles/bootstrap/_variables.scss";
#import "../../../shared/styles/bootstrap/_mixins";
#import "../../../shared/styles/app/variables.scss";
#import '~#swimlane/ngx-datatable/index.css';
#import '~#swimlane/ngx-datatable/themes/bootstrap.css';
#import '~#swimlane/ngx-datatable/themes/dark.scss';
#import '~#swimlane/ngx-datatable/themes/material.scss';
#import '~#swimlane/ngx-datatable/assets/icons.css';
#import "~#angular/cdk/overlay-prebuilt.css";
#import "~#angular/material/prebuilt-themes/indigo-pink.css";
.home-container {
margin: 0 auto;
max-width: map-get($container-max-widths, "lg");
.home-logo {
display: flex;
justify-content: center;
img {
width: 240px;
}
}
.home-text {
text-align: center;
#include media-breakpoint-up(lg) {
text-align: left;
}
}
.home-text-big {
font-size: 3.9375rem;
}
}
:host ::ng-deep .datatable-row-odd {
background-color: #eee;
}
:host ::ng-deep .datatable-header {
background-color: #f05050;
padding: 0.5rem 0 0 0.5rem;
font-size: 1.2rem;
}
:host ::ng-deep .datatable-body-cell {
vertical-align: middle;
padding: 0.5rem 0 0.5rem 0;
}
ol {
font-size: 2.25rem;
}
#manualInput p {
font-size: 1rem;
}
#allContent {
display: none;
}
#ptags {
font-size: 1rem;
}
ul{
list-style: circle;
padding: 0;
}
.secondLevel {
font-size: 1.5rem;
}
.container {
max-width: none;
}
input {
width: 100%;
}
button {
margin-bottom: 1rem !important;
width: 7rem;
}
hr {
margin-top: 1rem;
margin-bottom: 1rem;
border: 0;
border-top: 3px solid #dc3545;
}
.example-month-picker .mat-calendar-period-button {
pointer-events: none;
}
.example-month-picker .mat-calendar-arrow {
display: none;
}
::ng-deep .mat-form-field-underline {
visibility: visible;
z-index: -999;
display: block;
}
And HTML:
<mat-form-field appearance="fill">
<input matInput [matDatepicker]="dp" [formControl]="date">
<mat-datepicker-toggle matSuffix [for]="dp"></mat-datepicker-toggle>
<mat-datepicker #dp [touchUi]="true" disabled="false"
startView="multi-year"
(yearSelected)="chosenYearHandler($event)"
(monthSelected)="chosenMonthHandler($event, dp)"
panelClass="example-month-picker">
</mat-datepicker>
</mat-form-field>
The popup-window is rendered OUTSIDE the App-root actually, like this:
BTW, the mat-datepicker itself is positioned correct inside the app-root somewhere, but since i cant control the popup it gets positionen waay outside.
Does anyone have any suggestions? Tell me if you need something more, will respond quickly!
Thanks!
use
display="anchored"
I have a link on my menu items and id's on h2 of the text that belong to it. All I want to do is easy - when I click on certain item in the menu I want it to move down to the text that belongs to it. Easy.
I have it like side menu on the left and next to it is the text. When the resolution is under 479px the "side menu" is at the top and the text is under it. And what I want it to do is only when it is under this resolution - to jump down to the text (h2). When is it side by side it is fine and there is no need to do that of course. So my question is.. is it posiible to do so somehow only by using html and css? To make it work ("jump") only when it is under 479px? Media queries somehow?
Thanks you
<section id="budova">
<div class="materials">
<div class="container">
<h1>BUDOVA (izolace)</h1>
<div class="materials-container">
<div class="kategorie">
<h2 data-kategorie="#silsonic" class="active">Silsonic</h2>
<h2 data-kategorie="#mappysil400">Mappysil CR 400</h2>
<h2 data-kategorie="#mappysil404">Mappysil CR 404</h2>
<h2 data-kategorie="#polistik">Polistik / M under special HQ</h2>
<h2 data-kategorie="#pavisol">Pavisol</h2>
<h2 data-kategorie="#mappysilent">Mappysilent</h2>
<h2 data-kategorie="#fonosilent">Fonosilent</h2>
<h2 data-kategorie="#bugnato">Mappysil CR Bugnato</h2>
<h2 data-kategorie="#mappysil-re">Mappysil CR RE</h2>
<h2 data-kategorie="#mappypren">Mappypren AU</h2>
<h2 data-kategorie="#stopfire">Stopfire Bugnato</h2>
</div>
<div class="produkty" id="produkty">
<div id="silsonic" class="active">
<h3>Silsonic</h3>
<img src="./img/materials/budova/silsonic.jpg" alt="Silsonic">
<p>Cena od 150 kč vč. DPH</p>
<p>v 40/š 600/d 1200 mm ( ostatní rozměry v sekci ceník )</p>
<p>SILSONIC je termoizolační a akusticky absorpční materiál vyrobený z tepelně zpracovaných, recyklovaných polyesterových vláken. Panely SILSONIC se používají k tepelné a zvukové izolaci všech druhů zdiva, sádrokartonových konstrukcí, stropů a pro podstřešní izolace.</p>
</div>
.
.
.
more text
CSS
.materials-container {
display: grid;
grid-template-columns: 1fr 3fr;
margin: 3rem 0;
}
.materials h1 {
text-align: center;
padding: 6rem 0 1.5rem;
font-family: "Montserrat", sans-serif;
font-weight: 300;
letter-spacing: 1px;
border-bottom: 1px solid;
width: 90%;
margin: auto;
}
.kategorie {
background-color: #c4c4c4;
text-align: center;
padding: 1rem 0;
border-radius: 10px;
margin-bottom: 8rem;
}
.produkty {
display: flex;
justify-content: center;
/* align-items: center; */
margin-left: 10rem;
}
.produkty div {
display: none;
}
.produkty div.active {
display: initial;
}
.produkty h4 {
text-transform: uppercase;
margin-top: 3rem;
}
.produkty p:first-of-type,
.produkty p:nth-of-type(2) {
font-weight: 600;
}
.produkty img {
max-width: 300px;
}
.materials {
padding-bottom: 40px;
}
.materials p {
line-height: 24px;
}
.materials h1 {
margin-bottom: 5rem;
}
.materials h2 {
width: 70%;
cursor: pointer;
font-size: 1.2rem;
font-weight: 300;
padding: 0.8rem 0;
border-bottom: 1px solid transparent;
margin: 0 auto;
transition: all 0.3s;
}
.materials h2:hover {
border-bottom: 1px solid #fff;
color: #fff;
}
#media (max-width: 479px) {
.main-text p {
line-height: 2rem;
}
.main-text h1 {
padding: 4rem 0 0.5rem;
}
.photos img {
width: 60%;
margin: auto;
}
.photos {
height: 160px;
}
.nav-menu .logo {
width: 53%;
height: 52px;
}
.materials-container {
display: block;
}
.materials h2 {
font-size: 1.2rem;
}
.kategorie {
margin-bottom: 5rem;
}
#fonosilent {
width: 100%;
}
}
make an extra "link" in the html
on small screens one will be hidden (the one without jump-to-link) while the other one (with anchor-tag and jump-to) will be shown.
...
<div class="kategorie">
<h2 data-kategorie="#silsonic" class="active">Silsonic</h2>
<h2 data-kategorie="#silconic" class="active big-screen">Silsonic</h2>
...
media-queries in css:
#media (max-width: 479px) {
.big-screen {
display: none;
}
.small-screen {
display: grid/flex/whatever;
}
}
#media (min-width: 480px) {
.big-screen {
display: grid/flex/whatever;
}
.small-screen {
display: none;
}
}
I have been trying to figure this out, and just don't see what is wrong. So frustrating, but wanted to see if anyone can see why when resizing the browser window, the site is not responsive. However, inside of Chrome's and Firefox's inspector tools, I am able to see the website being responsive with different device sizes. I have been using #media screen (max-width) NOT device-width, which I know can cause this issue. I appreciate the help!
/***MEDIA QUERIES*****/
#media screen (max-width: 880px) {
#location-icon {
margin: 5px 10px 90px 0;
}
}
#media screen (max-width: 760px) {
.first-footer {
flex-direction: column;
}
#location-icon {
margin: 5px 10px 40px 0;
}
.copyright {
margin: 0;
}
.first-footer {
padding-bottom: 0;
}
}
#media screen (max-width: 375px) {
.intro {
flex-direction: column;
}
.intro img {
width: 100%;
}
.intro div {
padding-right: 0;
padding-bottom: 20px;
text-align: center;
}
.intro button {
margin: 40px 0;
}
.logo-button button {
padding: 20px;
width: 200px;
}
.logo-button img {
width: 100px;
}
.box {
flex-direction: column;
padding: 30px 40px;
text-align: center;
}
.mid-text {
order: 2;
padding: 0;
}
#location-icon {
margin: 5px 10px 100px 0;
}
.list1 {
margin: 30px 0 0 0;
}
.list2 {
margin: 0;
}
.icons {
align-self: center;
text-align: center;
margin-top: 30px;
}
.copyright {
margin: 0;
}
.first-footer {
padding-bottom: 0;
}
}
First off, you need to add "and" when you write a media query with two conditions like this :
#media screen and (max-width: 880px)
However the reason it isn't working is due to your container class in the body tag. If you remove it, it will fix most of your issues since there is no reason to use grid in that context
So, I have a website using lots of "ems" for fonts, they're literally everywhere. I managed to replace them all with rems, and now my media queries doesn't seem to be working as I've been changing my root font-size in them.
Here's the HTML:
<div id="em">
<h1>EMs are better?</h1>
<p>A text.</p>
</div>
<div id="rem">
<h1>REMs aren't?</h1>
<p>Sad panda.</p>
</div>
And CSS:
body {
font-size: 14px;
}
div {
margin: 10px;
padding: 20px;
text-align: center;
background: #efefef;
}
#em h1 { font-size: 2em; }
#em p { font-size: 1em; }
#rem h1 { font-size: 2rem; }
#rem p { font-size: 1rem; }
#media screen and (max-width: 500px) {
body {
font-size: 6px;
background: red;
}
}
Try resizing window to see what happens, REM box doesn't seem to change at all...
http://jsfiddle.net/Q5vSC/
Rem units are based off the font size of the html element, not the body.
Your css would change to this:
html { // changed from body to html
font-size: 14px;
}
div {
margin: 10px;
padding: 20px;
text-align: center;
background: #efefef;
}
#em h1 { font-size: 2em; }
#em p { font-size: 1em; }
#rem h1 { font-size: 2rem; }
#rem p { font-size: 1rem; }
#media screen and (max-width: 500px) {
html { // changed from body to html
font-size: 6px;
background: red;
}
}
Notice we target the html element in the first line and in the media query.
Here is your jsfiddle modified to work with rems.