How to scale another div in SCSS by clicking checkbox (without JavaScript)? - sass

Trying to scale a div in SCSS without using Javascript.
I know how to do this in CSS, but I can't get the syntax right in SCSS. How do I do?
When the checkbox is toggled, the external div should transform. I am using transform: scale().
Codepen link.
HTML:
<input type="checkbox" id="toggle" class="toggle" />
<div id="container">
<label for="toggle" class="nav-toggle-label">
Toggle me
</label>
</div>
<div class="responsive">
<ul class="nav-links">
<li>Link 1</li>
<li>Link 2</li>
</ul>
</div>
SCSS:
#container {
background: lightblue;
width: 10vw;
height: 10vh;
&:checked + .responsive {
transform: scale(1, 1);
}
}
.responsive {
background: orange;
width: 10vw;
height: 10vh;
transform: scale(1, 0);
}

In the css or scss/sass doesn't have bubbling behavior. In your case need to get the element in same level and get it with ~ selector. codepen example
#container {
background: lightblue;
width: 10vw;
height: 10vh;
}
.responsive {
background: orange;
width: 10vw;
height: 10vh;
transform: scale(1, 0);
}
#toggle:checked ~ .responsive {
transform: scale(1, 1);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/sass.js/0.11.1/sass.min.js"></script>
<input type="checkbox" id="toggle" class="toggle">
<div id="container">
<label for="toggle" class="nav-toggle-label">
Toggle me
</label>
</div>
<div class="responsive">
<ul class="nav-links">
<li>Link 1</li>
<li>Link 2</li>
</ul>
</div>

Related

Horizontal scrollbar inside angular-material (mat-tab) using FlexBox Grid

I am trying to implement a horizontal scroll bar to display images , but the width of the wrapper (scroll-container) container is overflowing. I also need to use FlexBox grid to make it responsive for different screen sizes.
Structure for HTML & SCSS is as given below. The container must be inside a mat-tab-group (Angular Material).
div 'item' will contain multiple items.
I am running it on chrome and have checked the inspector, apparently the mat-tab-body-wrapper display: flex property is causing this issue.
Is there any work around for this issue?
HTML
<mat-tab-group>
<mat-tab label="First">
<div class='row scroll-container'>
<div class='col-xs-5 col-sm-8 col-md-9 col-lg-12'>
<div class='horizontal-slider'>
<div class='slider-container'>
<div class='item'>
<img src='' alt=''>
</div>
</div>
</div>
</div>
</div>
</mat-tab>
</mat-tab-group>
SCSS
.scroll-container {
margin: 8px 0 0 0;
.horizontal-slider {
display: flex;
overflow-y: hidden;
max-width: inherit;
overflow-x: scroll;
box-sizing: border-box;
.slider-container {
.item {
display: flex;
margin-right: 8px;
img {
width: 124px;
height: 124px;
}
}
}
}
}
The most effective solution would be as shown below. Alongside the flex-nowrap you need to set the overflow attribute to prevent the whole page expanding.
With overflow property:
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<h6>Bootstrap 4 horizontally scrollable card groups</h6>
<div class="d-flex flex-row flex-nowrap overflow-auto">
<div class="card card-block mx-2" style="min-width: 300px;">Card</div>
<div class="card card-block mx-2" style="min-width: 300px;">Card</div>
<div class="card card-block mx-2" style="min-width: 300px;">Card</div>
</div>

How to render Vue component in hidden HTML element

In my app, I have the right slide bar that contains Vue components that represent system notifications. By default, the right bar is hidden (out of the screen) and when the user opens it the bar is blank(meaning no components displayed). In DevTools, I can see that Vue components weren't rendered
However, if I put the same code from right.blade.php to any normal view then every notification will be displayed.
My assumption so far, the Vue cannot render components in hidden HTML. Am I correct?
Here is the screenshot that demonstrates the presents of PHP code and the absence of Vue component, and the code itself:
right bar screenshot
rightbar.blade.php
<div id="rightbar" class="rightbar">
<div class="mt-2">
<ul class="nav nav-tabs2">
<li class="nav-item"><a class="nav-link active show" data-toggle="tab" href="#notifications">Notifications</a></li>
<li class="nav-item"><a class="nav-link" data-toggle="tab" href="#channels">Channels</a></li>
</ul>
<hr>
<div class="tab-content">
<div class="tab-pane show active" id="notifications">
#foreach(auth()->user()->unreadNotifications as $key => $notification)
<p>here</p> //<---------------------------this works
<notification props_id="{{$notification->id}}"
props_route="{{route('item.show',$notification['data']['item']).'#documents'}}"
props_title="New item uploaded"
props_body="User {{$notification['data']['name']}} uploaded {{$notification['data']['item']}}"
props_date="{{$notification->created_at}}">
</notification> //<------------------------- this doesn't works
#endforeach
</div>
<div class="tab-pane" id="channels">
<p>channel 1</p>
<p>channel 2</p>
<p>channel 3</p>
</div>
</div>
</div>
</div>
Notification.vue
<template>
<transition name="slide-fade">
<div class="card" v-show="showNotification" >
<div class="header">
<h2 v-text="title"></h2>
<ul class="header-dropdown dropdown">
<li><i class="fa fa-close"></i></li>
</ul>
</div>
<div style="cursor:pointer" #click="openSubject()">
<div class="card-body">
<p class="card-text" v-text="body"></p>
</div>
<div class="card-footer">
<small class="text-muted" v-text="date"></small>
</div>
</div>
</div>
</transition>
</template>
<script>
export default {
props: {
props_id: String,
props_route: String,
props_title: String,
props_body: String,
props_date: String,
},
name: "Notification",
data(){
return{
id: this.props_id,
route: this.props_route,
title: this.props_title,
body: this.props_body,
date: this.props_body,
showNotification: true,
}
},
methods:{
openSubject(){
location.href = this.route;
this.markAsRead()
},
markAsRead(){
axios
.put("/notifications/"+this.id)
.then(response => {
this.deleteNotification()
})
.catch(error => console.log(error))
},
deleteNotification(){
this.showNotification = false;
},
},
mounted() {
console.log('Vue notification')
}
}
</script>
<style>
.slide-fade-enter-active {
transition: all .3s ease;
}
.slide-fade-leave-active {
transition: all .5s cubic-bezier(1.0, 0.5, 0.8, 1.0);
}
.slide-fade-enter, .slide-fade-leave-to
/* .slide-fade-leave-active below version 2.1.8 */ {
transform: translateX(1000px);
opacity: 0;
}
</style>
app.js
Vue.component('notification', require('./components/Notification.vue').default);
rightbar.scss
.rightbar{
#include box-shadow(0 5px 10px 0px rgba($dark,.3));
#include transition(all .3s ease-in-out);
background: $body-color;
position: fixed;
top: 0;
right: -500px;
width: 500px;
height: 100vh;
overflow-y: scroll;
z-index: 13;
padding: 8px 20px;
&.open{
right: 0;
}
#include max-screen($break-medium) {
width: 450px;
}
#include max-screen($break-small - 1px) {
width: 340px;
}
.chat_detail{
display: block;
position: relative;
.chat-widget{
height: calc(100vh - 200px);
overflow-y: auto;
}
.input-group{
position: fixed;
bottom: 10px;
width: 460px;
#include max-screen($break-medium) {
width: 410px;
}
#include max-screen($break-small - 1px) {
width: 300px;
}
}
}
}
Your DevTools screenshot shows <notification> instead of the component's rendered elements, indicating that the component is not actually registered.
I would check the component registration in your view.

Images on nav bar before each link

Right, so I have made a navigation bar and I want to add images before each link, I know I can use a.header:before but I need different images for each link, a house for home, spanner for spec and so on. What is the simplest way of doing this? Is there a way without creating a div for each one and styling them individually?
For a preview of the page so far with the nav - http://zimxtrial.ukbigbuy.com/
One more thing - here is part of the css:
#header-nav {
background-color: #FFFFFF;
height: 80px; height: 8.0rem;
width: 100%;
position: absolute;
top: 50px;
}
.header-nav-center {
height: 80px; height: 8.0rem;
text-align: center;
position: relative;
top: 0px;
width: 500px; width: 50.0rem;
margin-left: auto;
margin-right: auto;
}
.header-nav-center ul {
margin: 0;
}
.header-nav-center ul li {
list-style: none;
margin: 0 35px 0 0;
display: inline;
}
a.header {
line-height: 80px; line-height: 8.0rem;
font-size: 17px; font-size: 1.7rem;
}
And HTML:
<div id="home">
<div id="header-nav">
<div id="hr-nav-top-container">
<hr class="nav" />
</div>
<div id="logo"></div>
<div class="header-nav-center">
<ul>
<li><a class="active" href="#home">Home</a>
</li>
<li><a class="header" href="#features">Features</a>
</li>
<li><a class="header" href="#specification">Specification</a>
</li>
<li><a class="header" href="#contact-us">Contact Us</a>
</li>
</ul>
</div>
<div id="pre-order"></div>
<div id="hr-nav-bottom-container">
<hr class="nav" />
</div>
</div>
</div>
Can I add something like:
a.header.home:before {
background: url('../images/home-logo.png') center center no-repeat;
}
Not that exactly but something like it?
You could make ids for each link and add the ids to the desired link img

How to make a row of three images responsive

Using Twitter Bootstrap 3, I have a container, three div place holders, and three images that fill as links each floated side by side and taking up the entire row: When I minimize the screen to make it responsive, I only see the first image (the second two dissapear). What steps would I have to take to make sure that each image becomes responsive and sits one below the other at the minimize dmobile display screen.
Please Note: Each Img. already has class="img-responsive" applied to it.
HTML:
<!--Wide Display Container -->
<div class="wide-display">
<div id="firstholder">
<a href="home.html" title="Home" class="imglink"><img src="/images/slide2.JPG" alt="City Lights Image" class="img-responsive" id="electricone">
<div class="item1">
<h1 class="slickfont1" >First Title</h1>
</div>
</a>
</div>
<div id="secondholder">
<a href="office.html" title="Office" class="imglink"><img src="/images/ant.JPG" alt="City Lights Image" class="img-responsive" id="electrictwo">
<div class="item1">
<h1 class="slickfont1" >Second Title</h1> </div></a>
</div>
<div id="thirdholder">
<a href="reviews.html" title="Locations" class="imglink"><img src="/images/family.JPG" alt="City Lights Image" class="img-responsive" id="thirdelectric">
<div class="item1">
<h1 class="slickfont1" > Third Title</h1>
</div>
</a>
</div>
</div><!-- Wide Display Container -->
CSS:
.wide-display {
min-width:33%;
position: relative;
width: 100%;
height:100%;
margin-top:6px;
overflow: hidden;
height:366px;
}
/*! First img Holder */
#firstholder {
width: 449px;
height: 100%;
float:left;
display:inline-block;
margin-left:1px;
margin-right:0px;
}
.item1 {
width: 24%;
margin: auto;
position:relative;
}
#secondholder {
width: 450px;
height: 100%;
float:left;
display:inline-block;
margin-right:0px;
}
#thirdholder {
width: 449px;
height: 100%;
float:left;
display:inline-block;
}
You have to create Bootstrap Grid to make it work. You can just read the documentation here: http://getbootstrap.com/css/ it's pretty easy to understand. The divs that wrap you images need to have grid classes applied to them.

FitTextJS plugin does NOT resize text when only the browser window HEIGHT changes

I have seven divs with id 1 to 7 in my html when I resize my window diagonally then the fittextjs plugin resizes the text within the 7 divs thats fine.
When I resize the window horizontally then the font-size decreases/increases fine...
What is not working as expected is: When I resize the window only vertically then the font-size does not decrease/shrink.
How can I make it work for the last non-working case?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>FitText</title>
<style type="text/css">
body, html {
width: 100%;
height: 100%;
font-family: arial;
/*overflow: hidden;*/
}
* { /* Every element which has a border or padding value puts this value inside the div */
box-sizing: border-box;
-moz-box-sizing: border-box;
padding: 0;
margin: 0;
}
._Z {
width: 12.50%;
}
.Stack {
display: table;
height: 100%;
float: left;
}
.Stack li {
list-style: none;
display: table-row;
}
.Stack li div {
display: table-cell;
}
.horizontal-right {
text-align: right;
}
.horizontal-center {
text-align: center;
}
.vertical-center {
vertical-align: middle;
}
#responseView {
height: 100%;
}
</style>
<!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
</head>
<body>
<div id="responseView" data-bind="swipeLeftRightContentViews: $root.showMapView">
<div style="height: 100%;">
<ul class="Stack _Z" data-bind="foreach: replyTimeStack.segments">
<li style="height:14.2%;background: green; color: black;">
<div id="div1" style="border-bottom:white solid 1px;" class="horizontal-center vertical-center">1</div>
</li>
<li style="height:14.2%;background: green; color: black;">
<div id="div2" style="border-bottom:white solid 1px;" class="horizontal-center vertical-center">2</div>
</li>
<li style="height:14.2%;background: green; color: black;">
<div id="div3" style="border-bottom:white solid 1px;" class="horizontal-center vertical-center">3</div>
</li>
<li style="height:14.2%;background: green; color: black;">
<div id="div4" style="border-bottom:white solid 1px;" class="horizontal-center vertical-center">4</div>
</li>
<li style="height:14.2%;background: yellow; color: black;">
<div id="div5" style="border-bottom:white solid 1px;" class="horizontal-center vertical-center">5</div>
</li>
<li style="height:14.2%;background: orange; color: black;">
<div id="div6" style="border-bottom:white solid 1px;" class="horizontal-center vertical-center">6</div>
</li>
<li style="height:14.2%;background: green; color: black;">
<div id="div7" style="border-bottom:white solid 1px;" class="horizontal-center vertical-center">7</div>
</li>
</ul>
</div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="jquery.fittext.js"></script>
<script type="text/javascript">
$("#div1").fitText(1.0, { minFontSize: '7px', maxFontSize: '16px' });
$("#div2").fitText(1.0, { minFontSize: '7px', maxFontSize: '16px' });
$("#div3").fitText(1.0, { minFontSize: '7px', maxFontSize: '16px' });
$("#div4").fitText(1.0, { minFontSize: '7px', maxFontSize: '16px' });
$("#div5").fitText(1.0, { minFontSize: '7px', maxFontSize: '16px' });
$("#div6").fitText(1.0, { minFontSize: '7px', maxFontSize: '16px' });
$("#div7").fitText(1.0, { minFontSize: '7px', maxFontSize: '16px' });
</script>
</body>
</html>
In order to make it work like that, you should tweak their resizer function in the script... setting up to measure the font size based on height rather than width.
$this.css('font-size', Math.max(Math.min($this.height() / (compressor*2), parseFloat(settings.maxFontSize)), parseFloat(settings.minFontSize)));
that should make it work based on the height..
Cheers!

Resources