menu appearing outside the screen border - css

I have a navBar menu. when clicked opens a submenu.
<nav class="navbar navbar-expand-md navbar-light bg-light">
<div class="collapse navbar-collapse" id="navegacao">
<ul class="navbar-nav mr-auto">
...
</ul>
<ul class="navbar-nav">
<div class="p-2"><i class="material-icons">face</i></div>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-toggle="dropdown">José da silva</a>
<div class="dropdown-menu" id="menuUsuario" style="padding: 2rem">
<app-menu-porteiro></app-menu-porteiro>
</div>
</li>
</ul>
</div>
</nav>
css
.dropdown-toggle::after {
display:none;
}
.dropdown-menu {
width: 300px;
}
#menuUsuario.dropdown-menu {
width: 300px;
}
#menuUsuario.dropdown-menu:before {
position: absolute;
top: -7px;
left: 4%;
display: inline-block;
border-right: 7px solid transparent;
border-bottom: 7px solid #ccc;
border-left: 7px solid transparent;
border-bottom-color: rgba(0, 0, 0, 0.2);
content: '';
}
#menuUsuario.dropdown-menu:after {
position: absolute;
top: -6px;
left: 4%;
display: inline-block;
border-right: 6px solid transparent;
border-bottom: 6px solid #ffffff;
border-left: 6px solid transparent;
content: '';
}
As shown in the image below, the menu goes beyond the stipulated area of the layout. I would like it to be aligned to the right margin.
I want it to fit within the limit of the screen. But as I'm new to css I can not solve this problem.

Related

To remove CSS border with diagonal edges

As you can see in the screenshot attached, I'm trying to remove the diagonal edges in the border. How can I go about it?
DEMO: https://jsfiddle.net/3cxn1pbs/
HTML:
<div class="container">
<div class="row mt-2">
<div class="col-3">
<div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
<a class="nav-link active" id="v-pills-home-tab" data-toggle="pill" href="#v-pills-home" role="tab" aria-controls="v-pills-home" aria-selected="true">Home</a>
<a class="nav-link" id="v-pills-profile-tab" data-toggle="pill" href="#v-pills-profile" role="tab" aria-controls="v-pills-profile" aria-selected="false">Profile</a>
<a class="nav-link" id="v-pills-messages-tab" data-toggle="pill" href="#v-pills-messages" role="tab" aria-controls="v-pills-messages" aria-selected="false">About</a>
<a class="nav-link" id="v-pills-settings-tab" data-toggle="pill" href="#v-pills-settings" role="tab" aria-controls="v-pills-settings" aria-selected="false">Settings</a>
</div>
</div>
<div class="col-9">
<div class="tab-content" id="v-pills-tabContent">
<div class="tab-pane fade show active" id="v-pills-home" role="tabpanel" aria-labelledby="v-pills-home-tab">Yo</div>
<div class="tab-pane fade" id="v-pills-profile" role="tabpanel" aria-labelledby="v-pills-profile-tab">...</div>
<div class="tab-pane fade" id="v-pills-messages" role="tabpanel" aria-labelledby="v-pills-messages-tab">...</div>
<div class="tab-pane fade" id="v-pills-settings" role="tabpanel" aria-labelledby="v-pills-settings-tab">...</div>
</div>
</div>
</div>
</div>
CSS
.nav {
border-radius: 4px;
border: solid 1px #dddddd;
background-color: #ffffff;
height: 100%;
min-height: calc(100vh - 200px);
}
.nav-pills .nav-link {
border-radius: 0;
}
.nav-pills .nav-link.active, .nav-pills .show>.nav-link {
color: #333;
background-color: #e6f8fd;
border-right: 4px solid #00b0e6;
border-radius: 0px;
font-weight: 600;
}
.nav-link {
border-bottom: 1px solid #ddd;
border-radius: 0;
color: #333;
}
.nav.flex-column a:first-child, .nav.flex-column a:first-child:hover {
border-top-right-radius: 3px !important;
border-top-left-radius: 3px !important;
}
.nav-link:hover {
color: #333;
background-color: #e6f8fd;
border-radius: 0px !important;
border-right: 4px solid #00b0e6;
}
The issue is because of you have both border-right and border-bottom, see how border behaves in follow snippet.
.container {
height: 100px;
width: 100px;
background-color: transparent;
border-top: 20px green solid;
border-right: 20px orange solid;
border-bottom: 20px silver solid;
border-left: 20px red solid;
}
<div class="container">
</div>
If you want no diagonal, you should remove diagonal on border-bottom, you can use the border-top instead to separate the tabs.
.nav .nav-link {
border-bottom: 0px !important;
}
.nav .nav-link {
border-top: 1px #dddddd solid;
}
For leaving spaces between each tabs:
You can also remove both border-top and border-bottom, use margin top/bottom for
the sub items, and adding background-color to the parent container.

Angular 8 components showing below sidebar instead of being on the side

I have a collapsible sidebar. On click of a link from the sidebar, I want to display the components next to the sidebar but they show below it.
My Component Code:
<app-topbar></app-topbar>
<div class="wrapper">
<app-sidebar></app-sidebar>
</div>
<div class="card" style="width: 18rem;">
<img class="card-img-top" src="assets/bn.jpg" alt="Card image cap">
<div class="card-body">
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
My Component's CSS:
.navbar{
background-color: #1F85DE;
}
.card{
flex: auto;
}
My Sidebar Component's HTML:
<nav id="sidebar" class="navbar-dark bg-#1F85DE" style="background-color: #1F85DE;" [ngClass]="{'hidden': sideNavService.hideSideNav }">
<hr>
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home Page</a>
<hr>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link2</a>
<hr>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link3</a>
<hr>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Profile</a>
<hr>
</li>
</ul>
</nav>
My Sidebars's CSS:
:host {
background: #343a40;
}
#sidebar {
min-width: 200px;
max-width: 200px;
min-height: 100vh;
color: #fff;
transition: all 0.3s;
font-weight: 300;
font-size: 1rem;
line-height: 1.5;
}
#sidebar.hidden {
margin-left: -200px;
}
a[data-toggle="collapse"] {
position: relative;
}
#media (max-width: 575px) {
#sidebar {
margin-left: -200px;
}
#sidebar.hidden {
margin-left: 0;
}
}
a, a:hover, a:focus {
color: inherit;
}
#sidebar .sidebar-header {
padding: 20px;
}
#sidebar ul li a {
padding: 15px;
display: block;
width: 100%;
&:hover {
background-color: rgba(255, 255, 255, 0.1);
}
}
hr {
border-top: 1px solid #fff;
margin-top: 0;
}
.dropdown-submenu {
position: relative;
}
.dropdown-submenu>.dropdown-menu {
top: 0;
left: 100%;
margin-top: -6px;
margin-left: -1px;
-webkit-border-radius: 0 6px 6px 6px;
-moz-border-radius: 0 6px 6px;
border-radius: 0 6px 6px 6px;
}
.dropdown-submenu:hover>.dropdown-menu {
display: block;
}
.dropdown-submenu>a:after {
display: block;
content: " ";
float: right;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
border-width: 5px 0 5px 5px;
border-left-color: #ccc;
margin-top: 5px;
margin-right: -10px;
}
.dropdown-submenu:hover>a:after {
border-left-color: #fff;
}
.dropdown-submenu.pull-left {
float: none;
}
.dropdown-submenu.pull-left>.dropdown-menu {
left: -100%;
margin-left: 10px;
-webkit-border-radius: 6px 0 6px 6px;
-moz-border-radius: 6px 0 6px 6px;
border-radius: 6px 0 6px 6px;
}
The code is making my Sidebar appear on the left side but the component that I want to display is not occupying the empty save on the right of the sidebar instead, after the sidebar ends, its occupying the save there.
<ng-sidebar-container>
<ng-sidebar [opened]="opened" position="right" mode="push" autoCollapseWidth=100>
<img src="assets/myimage_compressed.jpg" class="rounded-circle" width=80 height=80/>
<ul class="menu">
<li> <a routerLink="/">Dash Board</a></li>
<li> <a routerLink="/post">Post</a></li>
<li><a routerLink="/contact">Contact</a></li>
</ul>
</ng-sidebar>
<div ng-sidebar-content>
<!-- side page component ,Here i have used main component -->
<app-main></app-main>
</div>
</ng-sidebar-container>

Dropdown bootstrap got separated

I tried to make dropdown bootstrap menu and there is border at the bottom of the dropdown using <hr>
the problem is the dropdown menu jump the
<hr>
line.
here is the html
<div class="container">
<div class="row">
<div class="col-md-8">
<b>Available at :</b>
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
List<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
#foreach ($listings as $listing)
<li>Text</li><br>
#endforeach
</ul>
<hr>
</div>
under dropdown styling, there is top : 100% if I untick it, the dropdown list display correctly.
.dropdown-menu {
position: absolute;
top: 100%;
left: 0;
z-index: 1000;
display: none;
float: left;
min-width: 160px;
padding: 5px 0;
margin: 2px 0 0;
font-size: 14px;
text-align: left;
list-style: none;
background-color: #fff;
-webkit-background-clip: padding-box;
background-clip: padding-box;
border: 1px solid #ccc;
border: 1px solid rgba(0,0,0,.15);
border-radius: 4px;
-webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175);
box-shadow: 0 6px 12px rgba(0,0,0,.175);
Anyone know how to fix this so the dropdown will display exactly at the bottom of Available at :List ?
more like this
You could use top: 20px; left: 15px; instead of top: 100%; left: 0; in your css. this would fix your problem.
Look here: http://www.bootply.com/qyGxdV9m0t#
I fixed this with adding <div class="col-md-12"> before the dropdown. and another <div class="col-md-12"> for <hr>

dropdown menu doesn't open

I use an affix navbar, that stays fixed on top when scrolling down. I did a lot of changes yesterday, but now the dropdown menu won't open (or at least show)... I can't figure out where the problem lies.
Can anyone see it?
Sooooo: I testet some things. The problem seems to be, that I have following scripts at the end of the body:
<!------------------------------------------------------------ VENDOR JS -->
<script src="<?= DIR_VENDOR ?>jquery/jquery-1.12.4.min.js"></script>
<script src="<?= DIR_VENDOR ?>bootstrap/bootstrap.min.js"></script>
<script type="text/javascript" src="<?= DIR_VENDOR ?>slider/bootstrap-slider.js"></script>
<!------------------------------------------------------------ SYSTEM JS -->
<script src="<?= DIR_LIBRARIES ?>js/ajax.js"></script>
<script src="<?= $system['template']['web_path'] ?>script.js"></script>
I needed that for bootstrap slider to work. Can you tell me which ones I need to put back in the header again for the dropdown as well as the slider to work?
/********************************************************************* HEADER */
div.header.container-fluid {
width: 100%;
background-image: url(gfx/2.jpg);
background-size: cover;
height: 85vh;
background-attachment: fixed;
}
/********************************************************************** AFFIX */
.affix + .container-fluid {
padding-top: 70px;
}
.affix-top {
background-color: #db091a;
}
.affix-top a {padding: 10px 15px 0px 15px !important;}
.affix {
top: 0;
width: 100%;
-webkit-transition: all .5s ease-in-out;
transition: all .5s ease-in-out;
background-color: #3b3b3b;
border-top: 3px solid #db091a;
}
.affix a {
padding-top: 7px !important;
-webkit-transition: all .5s ease-in-out;
transition: all .5s ease-in-out;
}
/********************************************************************* NAVBAR */
div.navbar.navbar-custom {
-webkit-box-shadow: 0px 2px 10px 0px rgba(77,74,77,1);
-moz-box-shadow: 0px 2px 10px 0px rgba(77,74,77,1);
box-shadow: 0px 2px 10px 0px rgba(77,74,77,1);
border-radius: 0px;
z-index: 1030;
}
/* HEADER */
a.header.navbar-brand {
font-family: Josefin Sans;
font-size: 45px;
text-transform: uppercase;
color: #FFF;
line-height: 50px;
}
/* TOP */
ul.nav.navbar-nav.top {float: right !important;}
a.top {
font-family: 'Palanquin', sans-serif;
text-transform: uppercase;
font-weight: 500;
color: white;
padding: 0px;
margin: 0px 0px 0px 30px;
border-bottom: 3px solid transparent;
}
/* USER */
a.dropdown-toggle.user {padding: 0px 15px 0px 0px; margin-left: 20px;}
span.glyphicon.glyphicon-user {
color: #3b3b3b;
background-color: white;
padding: 5px;
font-size: 30px;
}
/* DROPDOWN */
ul.dropdown-menu {padding: 0px;}
div.collapse.navbar-collapse {padding: 0px;}
ul.nav.navbar-nav.bottom {float: right !important;}
a.dropdown-toggle.drop {
font-family: 'Palanquin', sans-serif;
text-transform: uppercase;
font-weight: 500;
color: white;
padding: 0px;
margin: 0px 0px 5px 30px;
border-bottom: 3px solid transparent;
}
a.dropdown-toggle.drop:hover {border-bottom: 3px solid #db091a;}
a.dropdown-toggle.drop:active {border-bottom: 3px solid #db091a;}
a.dropdown-toggle.drop:focus {border-bottom: 3px solid #db091a;}
<!-- START: HEADER -->
<div class="header container-fluid hidden-xs">
</div>
<!-- START: NAVBAR -->
<div class="navbar navbar-custom" data-spy="affix" data-offset-top="500" id="anker">
<div class="container-fluid">
<div class="row" id="anchor">
<div class="col-sm-6">
<a class="header navbar-brand" href="#"><?= $language['phrases']['site_title']; ?></a>
<button type="button" class="navbar-toggle " data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse">
<div class="col-sm-6">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<span class="glyphicon glyphicon-user hidden-xs"></span> <span class="hidden-sm hidden-md hidden-lg hidden-xl"> Benutzer <b class="caret"></b> </span>
<ul class="dropdown-menu">
<li>beispiel1</li>
<li>beispiel2</li>
<li>beispiel3</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<div class="row2">
<div class="container">
<div class="collapse navbar-collapse">
<div class="col-sm-12">
<ul class="nav navbar-nav bottom">
<li class="dropdown">
xMailer <b class="caret"></b>
<ul class="dropdown-menu">
<li>Advertiser</li>
<li>Kampagnen</li>
<li>Listen</li>
<li>Jobs</li>
<li>Nodes</li>
</ul>
</li>
<li class="dropdown">
Administration <b class="caret"></b>
<ul class="dropdown-menu">
<li>Konfigurationen</li>
<li>Module</li>
<li>Seiten</li>
<li>Navigation</li>
<li>Gruppen</li>
<li>Benutzer</li>
<li>Sprachen</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- END: NAVBAR -->
ok problem solved!
the scripts in the html body were the reason for the missing dropdown menu!

Showby arrow dissapears when applying overflow: auto

I'm trying to style a select dropdown menu in order to overflow when arriving to 150px height. The problem is that when I apply the overflow: auto property, the after pseudoelement containing an arrow pointing to the select disappears.
Here we've the code:
.dropdown-menu{
background-color:#f2f2f1;
min-width: 100px;
border:none;
border-top:5px solid #b4b4b4;
border-radius:0;
>li>a{
font-size: 14px !important;
color:#818181 !important;
&:hover, &:active{
color:#003e59 !important;
}
}
.divider{
height:2px;
margin: 2px 0;
background-color:#cdcccd;
}
&:after {
bottom: 100%;
left: 25%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(136, 183, 213, 0);
border-bottom-color: #b4b4b4;
border-width: 12px;
margin-left: -12px;
}
}
<div class="input-group">
<label>Jurisdiction</label>
<button class="btn btn-default btn-sm dropdown-toggle" type="button" data-toggle="dropdown">
Select Jurisdiction <span class="spacer"></span><span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li>Jurisdiction 1</li>
<li class="divider"></li>
<li>Jurisdiction 2</li>
<li class="divider"></li>
<li>Jurisdiction 3</li>
</ul>
</div>

Resources