I have an angular app (v6.1) which uses angular flex & Angular flex-layout. I am using angular v6.1 to make use of the fragment scroll feature. My page has a toolbar, side navigation with links to fragments within page and a center content(see the picture below). My requirement is to have the toolbar and left nav fixed while the center content alone should scroll. Following is my app.component.html. with this html, the whole of the page scrolls and not just the center content. How can I achieve the desired behaviour?
app.component.html
<div fxLayout="column">
<div fxFlex="20%" fxFlexFill style="background-color: rgb(48, 138, 133); ">
<mat-toolbar color="primary">
<mat-toolbar-row fxLayoutGap="10px">
<a type="button" href="#one">Menu item #1</a>
<a type="button" href="#two">Menu item #2</a>
</mat-toolbar-row>
</mat-toolbar>
</div>
<div fxFlex="80%">
<div fxLayout="row" style="background-color: cadetblue">
<div fxFlex="20%" fxLayout="column" style="background-color: chocolate">
<a mat-button routerLink="./" routerLinkActive="active" fragment="one">Nav Link #1</a>
<a mat-button routerLink="./" routerLinkActive="active" fragment="two">Nav Link #2</a>
<a mat-button routerLink="./" routerLinkActive="active" fragment="three">Nav Link #3</a>
<a mat-button routerLink="./" routerLinkActive="active" fragment="four">Nav Link #4</a>
<a mat-button routerLink="./" routerLinkActive="active" fragment="five">Nav Link #5</a>
</div>
<div fxLayout="column" fxLayoutGap="100px" fxFlex="100%"
style="background-color: chartreuse;">
<p id="one">para 1</p>
<p id="two">para 2</p>
<p id="three">para 3</p>
<p id="four">para 4</p>
<p id="five">para 5</p>
<p id="six">para 6</p>
<p id="seven">para 7</p>
<p id="eight">para content 8</p>
</div>
</div>
</div>
</div>
Okay. There's a few things that you need to do to make this work.
First, you need to make sure your body has a height of 100%. Otherwise, whenever an element is given a height of 100%, it won't know "100% of what" and will just grow as much as it wants.
The next thing you want is adding this style in a few places: height: 100%; overflow: auto. This says "the element fills it's parent, and if the content grows any bigger, make the content scrollable". Specifically, add these styles to the two inner columns.
stackblitz with result
One of the Best way to do what you require is
By creating the sidenav and toolbar as a separate component and rendering child components in the body (the green area )
Just like
<header role="mast-head">
<div class="container-fluid">
//Your header will come here
</div>
</header>
<div class="side bar">
<ul>
<li routerLinkActive="active" [routerLink]="['/homepage/h']"><img src="" alt="" />Dashboard</li>
<li routerLinkActive="active" [routerLink]="['/homepage/dst']"><img src="" alt="" />A</li>
<li routerLinkActive="active" [routerLink]="['/homepage/j']"><img src="" alt="" />B </li>
</ul>
</div>
<div class="body">
<router-outlet >
</router-outlet>
</div>
Related
I am using Bulma and I made an hoverable dropdown, but the dropdown content exceeds the whole page content. How can I make it fixed with larger width and also responsive?
For now it looks like this:
Html code:
<div class="navbar-end">
<div class="dropdown is-hoverable navbar-item ">
<div class="dropdown-trigger">
<button aria-controls="dropdown-menu6" aria-haspopup="true" class="button is-primary">
<strong>Account</strong>
</button>
</div>
<div class="dropdown-menu has-text-centered" id="dropdown-menu6" role="menu">
<div class="dropdown-content">
<div class="dropdown-item">
<p>Acces your quizbee account, test your skills and have fun. </p>
<hr class="dropdown-divider">
<div class="buttons is-centered">
<button class="button is-primary is-rounded">Register</button>
<button class="button is-light is-rounded">Login</button>
</div>
</div>
</div>
</div>
</div>
You just need to set a position of dropdown. Add class is-right
<div class="dropdown is-right is-active">
I have a pure CSS accordion, it works great, but an issue is handling click shifting the screen up to the anchor tag;
<div class="collapse-content">
<div class="collapse" id="instagram">
<a class="instagram" href="#instagram" onClick="return false;"><i class="fab fa-instagram"></i>Insta</a>
<div class="content">
<div class="inner-content">
Insta content
</div>
</div>
</div>
<div class="collapse" id="twitter">
<a class="twitter" href="#twitter"><i class="fab fa-twitter"></i>Twitter</a>
<div class="content">
<div class="inner-content">
Twitter content
</div>
</div>
</div>
<div class="collapse" id="dribbble">
<a class="dribbble" href="#dribbble"><i class="fab fa-dribbble"></i>Dribble</a>
<div class="content">
<div class="inner-content">
Dribble content
</div>
</div>
</div>
</div>
How can I suppress the browser scrolling the anchor to the top of the screen? I've tried adding a ? ! and 0 to the end of the anchor, but that breaks the link from working and as you can see above I've tried onClick="return false;" which stops the click. I'm guessing what I need is some sort of offset, as I don't want to suppress the click event just the scrolling too.
# the moment I'm avoiding using Jquery, ideally no JS but trying to keep it as simple as possible.
If these aren't links, then you shouldn't be using <a> tags. Links can:
link to another document
link to another part of the same document
In this case, clicking triggers an action, you should use a <button type="button"> tag.
I have two div fields that are causing the window to scroll right. I don't understand how to change the weight or length so that the window is only scrolling up and down not left and right.
This is part of the navbar that deals with the dropdown menu
<span class="navbar-text" class="w-25">
<ul class="navbar-nav mr-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Account
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#">Register</a>
<a class="dropdown-item" href="#">Login</a>
<a class="dropdown-item" href="#">Advertise</a>
</div>
</li>
</ul>
This is the dropdown. You can see that when dropdown it expands and you have to scroll right on the page to see the dropdown box
Here are the cards the div box for these are also too big and cause the page to scroll right
<section class="features-icons bg-white text-center">
<h1>
<center><b>Explore Rentals in Island</b></center>
</h1>
<div class="card-deck">
<div class="card">
<img class="card-img-top" src="./img/home-icon.jpg" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Name</h5>
<p class="card-text">Location</p>
<p class="card-text">Price</p>
</div>
</div>
<div class="card">
<img class="card-img-top" src="./img/home-icon.jpg" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Name</h5>
<p class="card-text">Location</p>
<p class="card-text">Price</p>
</div>
</div>
<div class="card">
<img class="card-img-top" src="./img/home-icon.jpg" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Name</h5>
<p class="card-text">Location</p>
<p class="card-text">Price</p>
</div>
</div>
</div>
<br>
<br>
<button type="button" class="btn btn-primary btn-lg">View More</button>
</section>
Image of the nav bar error
Image of the cardbox error
Consider this code snippet.
section.features-icons.bg-white.text-center{
overflow: hidden;
width: 100%;
}
[aria-labelledby="navbarDropdownMenuLink"]{
margin-left: -53px;
}
Here are the two contributing factors to why your dropdown menu list is so wide:
1) In the dropdown-menu class, the min-width is set to 10rem
2) In the dropdown-item class, the left right padding is set to 1.5rem
If you go to DevTools and disable these two properties, the dropdown will fit within your browser again, but probably a bit too tight around the list items texts.
I would create my own css classes to
1) set min-width of dropdown-menu class to 0rem
2) reduce the left right padding of dropdown-item to something that looks nice but not too wide
I quickly scribbled this together:
.fix-min-width {
min-width: 0;
}
.fix-padding {
padding: 0.25rem 0.75rem;
}
Hope this helps.
I try create a card with bootstrap+animate.css
PLEASE check with google chorme last version:
<div class="shop-card well">
<h3>title 1</h3>
<a href="/">
<figure class="figure">
<img class="figure-img img-fluid img-rounded" src="http://wewswiderska.home.pl/images/3dspace.html-i1.png">
</figure></a>
<div class="price">1234 <span class="symbol">R</span>
<del>5678</del>
</div>
<form class="hide buys" id="inform-ordering-5" name="inform-ordering-5" role="form" style="overflow: hidden;position: absolute;left:-1px;width: 100%; bottom: -1px;">
<div class="btn-group btn-group-justified">
<a class="btn btn-danger" data-target="#phoneModal" data-toggle="modal" href="#">modal</a>
</div>
</form>
</div>
I want When I move my mouse over the card, A red button appears. And then disappear.
ّI done it.
ّNow when I click on the button, It opens a modal box.
I done it!
But this is my problem:
when I close the modal box, contaners of card floats to left!
here is a demo: https://jsfiddle.net/1pyeg7w2/
I couldn't solved it.
I wrapped your div.shop-card.well content with another div with position:relative rule and it seems to be working
<div class="shop-card well">
<div style="position:relative">
your content here
</div>
</div>
As the title suggests I want to change the color of the actual modal, not the shaded area behind the modal. As this post says. I just want to change the color of the modal. Heres some code:
<div class="portfolio-modal modal fade" id="HighSchoolModal" tabindex="-1" role="dialog" aria-hidden="true" style="background-color:#F07A1A !important;">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl">
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<div class="modal-body">
<h2>Parktown Boys' High</h2>
<hr class="star-primary">
<img src="img/portfolio/park.jpg" class="img-responsive img-centered" style="width:50%" alt="">
<p>Use this area of the page to describe your project. The icon above is part of a free icon set by Flat Icons. On their website, you can download their free set with 16 icons, or you can purchase the entire set with 146 icons for only $12!</p>
<ul class="list-inline item-details">
<li>Client: <strong>Start Bootstrap</strong>
</li>
<li>Date: <strong>April 2014</strong>
</li>
<li>Service: <strong>Web Development</strong>
</li>
</ul>
<button type="button" class="btn btn-default" data-dismiss="modal"><i class="fa fa-times"></i> Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
I've used style="background-color:#F07A1A !important;" on the code and in the chrome element inspector it shows the color is in being applied:
The problem... my modal is still white. Any ideas how I can change the background color?
Apply the styling to .modal-content.
$(".modal").on('shown.bs.modal', function() {
$('.modal-backdrop').css('background', '#00000073');
});
best way is to overwrite bootstrap variable
Bootstrap have a variable called $modal-content-bg
You would need to overwrite this variable to change the background color of modal. This is what worked for me.