I have an angular app in which i have my nested dropdown menu. And in one of the list item i have primeng Tabview in that list item like this
<li *ngIf="user.role !== 'super'" class="nav-item flex-center-center flex-column min-width-40 no-border custom-bell-padding notifications-dropdown">
<a class="nav-link" id="notificationsDropDown" role="button" data-toggle="dropdown" aria-haspopup="true">
<i class="fal fa-bell font-26"></i>
</a>
<div class="dropdown-menu" aria-labelledby="notificationsDropDown" (click)="onClick($event)">
<span class="dropdown-menu-arrow"></span>
<div class="ui-g header-dropdown-list">
<div class="ui-g-12 list-item-border-bottom">
<div class="ui-g-6">
<p class="font-11 pb-0">Your Notifications</p>
</div>
<div class="ui-g-6 font-11 text-right">
<app-checkbox [disabled]="disabled" label="Technician updates" [isChecked]="true"></app-checkbox>
</div>
</div>
<div class="ui-g-12">
<p-tabView class="tab-panel-underline">
<p-tabPanel header="All">
<ng-template pTemplate="content">
</ng-template>
</p-tabPanel>
<p-tabPanel header="Critical">
<ng-template pTemplate="content">
</ng-template>
</p-tabPanel>
</p-tabView>
</div>
</div>
</div>
Now i am applying custom styling in component.scss like this
.notifications-dropdown{
.dropdown-menu {
left: 843px !important;
margin: -0.875rem 0 0;
font-size: 0.875rem;
color: #7A8281;
text-align: left;
list-style: none;
border: 0 solid #c8ced3;
box-shadow: 0px 3px 6px #00000029;
z-index: 99999;
top: 74px;
border-radius: 0px;
width: 20rem;
/* min-width: 18.2rem; */
/* right: 0px; */
.header-dropdown-list{
// height: 150px;
.list-item-border-bottom{
border-bottom: 1px solid #e5e6e6;
}
p-tabview.tab-panel-underline {
.ui-tabview{
padding: 20px !important;
.ui-tabview-nav li{
width: 50% !important;
padding: 0px !important;
}
}
}
}
}
But my styling is not applying on primeng tabview. I have this tabview inside of my main list item i.e li and applying some padding and width of li of primeng tabview but it's not applying my custom styles.
I have fixed this issue. The problem was causing due to ViewEncapsulation. My problem solved when i put ViewEncapsulation.None inside my component.
You can use ng-deep and & opertor in scss which refrence to parent class.
::ng-deep .notifications-dropdown{
.dropdown-menu {
left: 843px !important;
margin: -0.875rem 0 0;
font-size: 0.875rem;
color: #7A8281;
text-align: left;
list-style: none;
border: 0 solid #c8ced3;
box-shadow: 0px 3px 6px #00000029;
z-index: 99999;
top: 74px;
border-radius: 0px;
width: 20rem;
/* min-width: 18.2rem; */
/* right: 0px; */
.header-dropdown-list{
// height: 150px;
& .list-item-border-bottom{
border-bottom: 1px solid #e5e6e6;
}
& p-tabview.tab-panel-underline {
& .ui-tabview{
padding: 20px !important;
& .ui-tabview-nav li{
width: 50% !important;
padding: 0px !important;
}
}
}
}
}
Related
this might be an easy one.
This is how my pure css menu currently looks like:
html, body {
margin:0;
padding: 0;
font-family: arial;
}
/* Menu */
.menu__wrapper {
background: #fff;
z-index: 8000;
min-height: 30px;
box-shadow: 0px 1px 5px 0px rgba(0,0,0,0.75);
}
/* The dropdown container */
.dropdown {
float: left;
overflow: hidden;
}
/* Main links */
.menu__mainlink {
cursor: pointer;
border: none;
color: $dark-color;
padding: 5px 16px;
display: inline-block;
}
/* Sublinks */
.menu__sublink {
font-size: 16px;
padding: 5px 16px;
text-decoration: none;
display: block;
}
.menu__mainlink, .menu__sublink:hover {
color: red;
text-decoration: none;
}
/* Dropdown content (hidden by default) */
.dropdown-content {
display: none;
position: absolute;
background-color: #fff;
width: 100%;
left: 0;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Sticky header */
.menu__wrapper.sticky {
position: fixed;
background-color: #fff;
width: 100%;
top: 0px;
}
/* Dropdown button */
.sticky .dropdown .dropbtn, .sticky a {
color: #000;
}
<div class="menu__wrapper padding-left-large sticky">
<div class="dropdown no-padding-left">
<a class="menu__mainlink" href="#">Main</a>
<i class="fa fa-caret-down"></i>
<div class="dropdown-content">
<a class="menu__sublink" href="#">Information</a>
<a class="menu__sublink" href="#">Archiv</a>
<a class="menu__sublink" href="#">Kontakt</a>
<a class="menu__sublink" href="#">Impressum</a></div>
</div>
<div class="dropdown no-padding-left">
<a class="menu__mainlink" href="#">Program</a>
<i class="fa fa-caret-down"></i>
<div class="dropdown-content show">
<a class="menu__sublink" href="#">This</a>
<a class="menu__sublink" href="#">That</a>
<a class="menu__sublink" href="#">Really_long_menu_item</a>
<a class="menu__sublink" href="#">Calendar</a></div>
</div>
<div class="dropdown no-padding-left">
<a class="menu__mainlink" href="#">Found</a>
<i class="fa fa-caret-down"></i>
<div class="dropdown-content">
<a class="menu__sublink" href="#">Videos</a>
<a class="menu__sublink" href="#">Image</a>
<a class="menu__sublink" href="#">Sound</a>
<a class="menu__sublink" href="#">Text</a>
</div>
</div>
</div>
Pen: https://codepen.io/t-book/pen/yLNwRba?editors=1100
Question 1: How can I color red the parent menu item like "main" when hovering over its subitems (like Archiv or Kontakt)?
Question 2: How could I push the absolute positioned submenu left to align it under its parent? The moment I position the submenu relative it will keep the x of its parent but unfortunately, in case of really long submenu names, it pushes the next floated parent item right.
Answer 1:
.dropdown:hover> a{color:red;}
Answer 2:
remove overflow:hidden; to .dropdown
add position:relative; to .dropdown
remove width: 100%; from .dropdown-content
I am having trouble with using margin-left with safari
here's my css
<style>
.profile___options {
position: absolute; width: 828px; height: 45px; border-top: 1.1px solid #eee; margin-top: 97px; margin-left: 282px;
}
.profile___options ul {
float: right;
margin-right: 329px;
}
.profile___options ul li {
border-right: 1px solid #e9eaed;
float: left;
font-size: 15px;
font-weight: 600;
height: 43px;
position: relative;
list-style: none;
vertical-align: middle;
white-space: nowrap;
cursor: pointer;
padding: 16px;
color: #365899;
padding: -1px;
}
</style>
and here's my html code
<div class="profile___options">
<div class="fsaafFDSA__">
<div class="223__adAas">
<div class="profile___options_inner">
<ul class="user_ul">
<li>
<a class="questions_link">Questions</a>
</li>
<div class="user_bookmark" style="
position: absolute;
margin-left: -121px;">
</div>
<li style="width: 136px;" class="followerLink">
<!--<span class="badge badge-danger" style="color: #fff;background-color: #dc3545;width: 19px;margin-top: 5px;position: absolute;margin-left: -7px;">3</span>-->
Followers
</li>
<li style="width: 136px;" class="followingLink">
<!--<span class="badge badge-danger" style="color: #fff;background-color: #dc3545;width: 19px;margin-top: 5px;position: absolute;margin-left: -7px;">3</span>-->
Following
</li>
</ul>
</div>
</div>
</div>
</div>
and here's the result on chrome
result on chrome
and here's the result on safari
Result on safari
what I am trying to accomplish is to keep the bottom navbar with the black outline to be aligned at the same place on both browsers
Thanks,
Arnav
Try this:
-webkit-margin-start (left)
-webkit-margin-end (right)
https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariCSSRef/Articles/StandardCSSProperties.html
Hope I helped.
Ok so here is a blueprint of what I am trying to do and some element outlines:
Alright, so as we see I want to move the logout button to the center of the div it is in (.paper).
So this is working:
button[id="centerprofile"]{
text-align: center;
margin-left: 44%;
}
However, I don't like using this margin-left: 44%; hack. Without this hack, the button just stays to the left even with text-align: center;.
How can I center this button perfectly to the .paper element it is in? Here is the rest of my code:
HTML:
<body>
<ul class="topnav">
<li><i class="fa fa-rocket" aria-hidden="true"></i> Play</li>
<li><i class="fa fa-btc" aria-hidden="true"></i> Deposit</li>
<li><i class="fa fa-btc" aria-hidden="true"></i> Withdraw</li>
<li><i class="fa fa-university" aria-hidden="true"></i>Faucet</li>
<li><i class="fa fa-life-ring" aria-hidden="true"></i>Help & Support</li>
<?php echo $accountButton; ?>
<li class='right' id="top-balance"></i>" . $balance . "BTC"; ?></li>
</ul>
<div class="paper">
<?php echo $contentDump; ?>
</div>
</body>
PHP $contentDump:
$contentDump =
"
<h2>Profile</h2>
<p>Account balance: " . $balance . "BTC</p>
<button id='centerprofile'>Logout</button>
";
CSS (.button, .paper, and button[id="centerprofile"]):
button[id="centerprofile"]{
text-align: center;
}
button {
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
.paper{
border: 6px solid white;
height: auto;
margin: 20px;
padding: 20px;
width: auto;
background-color: white;
margin-left: 3%;
margin-right: 3%;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
font-family: "smooth";
}
Make it a block element so you can use auto margins to center it:
button[id="centerprofile"]{
display: block;
margin-left: auto;
margin-right: auto;
}
You can use this hack:
button[id="centerprofile"]{
display: block;
margin: 4px auto;
}
The correct answer should be to center the container of the button as noted in the comment by #arbuthnott
.paper {
text-align:center;
}
I would like to evenly space the 3 links ('About', 'Hours', 'Contact') within the containing 'banLinks' div. I do not want to use a list of any kind.
I would like each link to be evenly spaced, taking up 1/3 of their container. I am very new to HTML and CSS and I'm not sure how to do this.
I think one way of doing it may be by dividing the width of the div container in pixels by 3, account for the font size, then set the margins somehow around this figure. But to me this seems a bit unseemly, I'n not sure if this is the done thing.
<body>
<div id="wrapper">
<div class="bruceBanner">
<a href="#">
<img border="0" alt="XYZ Banner" src="http://bit.ly/1QSpdbq" width="553" height="172">
</a>
</div>
<nav>
<div class="banLinks">
<a id="about" href="#">About</a>
<a id="hours" href="#">Hours</a>
<a id="contact" href="#">Contact</a>
</div> </nav>
</div><!-- .wrapper-->
</body>
CSS:
#wrapper {
}
.bruceBanner img {
border: 2px solid black;
height: 172px;
width: 553px;
display: block;
margin: 0 auto;
}
.banLinks {
border: 2px solid black;
width: 553px;
text-align: center;
margin: 0 auto;
}
#about, #hours, #contact {
font-size: 20px;
border: 2px solid blue;
}
Here is a jsfiddle. https://jsfiddle.net/yuy84gmq/6/
you can do this using flexbox. Do as followed:
.banLinks {
border: 2px solid black;
width: 553px;
text-align: center;
margin: 0 auto;
display: flex;
justify-content: space-around; //or space-between whatever you like best
}
JSfiddle: https://jsfiddle.net/yuy84gmq/10/
flexbox: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
Add this to style:
.banLinks {
border: 2px solid black;
width: 553px;
text-align: center;
margin: 0 auto;
padding: 0;
}
.banLinks a{
width: calc(33% - 4px);
display: inline-block;
margin: 0;
}
Use a display table
.banLinks {
display:table;
table-layout:fixed;
border: 2px solid black;
width: 553px;
text-align: center;
margin: 0 auto;
}
.banLinks a {
display:table-cell;
}
Here is the fiddle: https://jsfiddle.net/yuy84gmq/8/
A couple of options here...both of which work regardless of the number of list items...assuming there is enough width.
Display:Table-cell
.banLinks {
border: 2px solid black;
width: 553px;
text-align: center;
margin: 0 auto;
display: table;
}
.banLinks a {
display: table-cell;
border: 1px solid grey
}
<div class="banLinks">
<a id="about" href="#">About</a>
<a id="hours" href="#">Hours</a>
<a id="contact" href="#">Contact</a>
</div>
Flexbox
.banLinks {
border: 2px solid black;
width: 553px;
text-align: center;
margin: 0 auto;
display: flex;
}
.banLinks a {
flex: 1;
border: 1px solid grey
}
<div class="banLinks">
<a id="about" href="#">About</a>
<a id="hours" href="#">Hours</a>
<a id="contact" href="#">Contact</a>
</div>
Instead of usual a links, put them into a list, and set the list to be inline. Then you can apply margin to the list items to space them out.
HTML
<nav>
<ul class="banLinks">
<li><a id="about" href="#">About</a></li>
<li><a id="hours" href="#">Hours</a></li>
<li><a id="contact" href="#">Contact</a></li>
</ul>
</nav>
CSS
.banLinks li { display:inline-block;margin:0 10px;} /* Adjust left/right margin as appropriate */
I'm trying to use angular to create list of elements. The page will be an app on mobile phone.
The list itself can have many elements so what I expect is that the ul element should be scrollable ("swipable"?). I tried to follow some example like http://jsfiddle.net/sirrocco/9z48t/ and http://jsfiddle.net/qcv5Q/1/..
This is the html code:
<div class="container">
<div id="spinner-icon" style="display:none">
<span class = "icon-spinner"></span>
</div>
<div class="col-xs-12 indentation push-down bg-white" ng-repeat="cei in completeElementInfo">
<div class="clearfix">
<div class="pull-left">
<h4>{{cei.description}}</h4>
<p>{{cei.name}}</p>
</div>
</div>
<div class="log-widget-list">
<ul class="list scroller clearfix" id="elements-list">
<li class="pull-left" ng-repeat="tinfo in cei.techInfo | orderBy: 'tinfo.sentTime'">
<h4 class="align-center">{{tinfo.elementShortCode}}</h4>
<div class="clearfix">
<span class="icon-clock pull-left"></span>
<span class="pull-right"> {{tinfo.sentTime}}min</span>
</div>
</li>
</ul>
</div>
</div>
</div>
and this is the css code:
.list {
margin: 0;
padding: 0;
}
.log-widget-list {
height:100px;
width: 720px;
overflow: hidden;
}
.log-widget-list .scroller{
overflow-x: scroll;
list-style-type: none;
width: 1500px; /* combined width of all LI's */
}
#elements-list li {
width: 100px;
list-style: none;
box-sizing: border-box;
border-top: none!important;
background-color: #0accf8;
padding: 4px;
}
#elements-list li:not(:last-of-type) {
border-right: 3px solid #ffffff;
}
#elements-list [class^="icon-"], #elements-list [class*=" icon-"] {
margin-top: 4px;
font-size: 12px;
}
Now the problem is that i don't want that the horizontal scrollbar appears, but it appears and i don't understand why... Any idea?
add overflow:hidden in #wrapper css.
CSS:
#wrapper {
background: transparent;
width: 550px;
color: white;
height:100%;
overflow:hidden;
}
Demo: http://jsfiddle.net/lotusgodkk/9z48t/5/
DEMO
http://jsfiddle.net/FTUrF/6/
Changed some CSS here:
.log-widget-list {
width: 200px;
height: 300px;
border: 1px solid #000;
overflow: hidden;
}
.log-widget-list .scroller {
width: 215px;
height: 300px;
overflow: scroll;
padding-bottom: 15px;
list-style-type: none;
}
Added height and padding-bottom in .scroller and border in .log-widget-list
and added some more of these:
<span class="pull-right"> {{tinfo.sentTime}}min</span>