i just found an issue on my web project and i couldnt find a way around it.
i saw something about sprites and a blog that mentions this issue.
everything looks fine on 100% but when i zoom in with my browser the icons get bigger and bigger and break the layout.
this is what my css look like
.Sidebar {
position: fixed;
background-color: #262626;
width: 5%;
height: 100%;
z-index: 1;
}
.Sidebar-Icon {
align-items: center;
font-size: 30px;
}
.Sidebar-Icon .SDIcon {
text-decoration-line: none;
}
.Sidebar-Icon li {
list-style-type: none;
}
ul.Sidebar-Icon {
cursor: pointer;
display: flex;
padding: 0;
flex-direction: column;
align-items: center;
flex: 1;
margin: 0;
height: 100%;
position: relative;
}
.Sidebar-Icon li:first-child{
padding: 20px 0 0 0;
}
.Sidebar-Icon li:first-child,
.Sidebar-Icon li:last-child{
margin-bottom:auto;
}
.sb-i{
color: #999AAA !important; // shadow AAABBB
}
Html (Angular) Code
<div class="Sidebar" [#collapse]="collapse">
<div class="Sidebar-Inner">
<div class="profileimg"></div>
</div>
<ul class="Sidebar-Icon ">
<li><a class="sb-i" (click)="toggleCollapse()">
<i class="fas fa-ellipsis-v" ></i></a></li>
<li><a class="sb-i"href="javascript:void(0)"><i class="fas fa-home"></i></a>
</li>
<li><a class="sb-i"href="javascript:void(0)"><i class="fas fa-child"></i>
</a></li>
<li><a class="sb-i"href="javascript:void(0)"><i class="fab fa-accessible-
icon"></i></a></li>
<li><a class="sb-i"href="javascript:void(0)"><i class="fas fa-cog"></i></a>
</li>
</ul>
</div>
example of the issue (Zoomlevel on 500%):
HTML:
<div class="Sidebar" [#collapse]="collapse">
<div class="Sidebar-Inner">
<div class="profileimg"></div>
</div>
<ul class="Sidebar-Icon ">
<li><a class="sb-i" (click)="toggleCollapse()">
<i class="fas fa-ellipsis-v" ></i></a></li>
<li><a class="sb-i" href="javascript:void(0)"><i class="fas fa-home"></i></a>
</li>
<li><a class="sb-i" href="javascript:void(0)"><i class="fas fa-child"></i>
</a></li>
<li><a class="sb-i" href="javascript:void(0)"><i class="fab fa-accessible-
icon"></i></a></li>
<li><a class="sb-i" href="javascript:void(0)"><i class="fas fa-cog"></i></a>
</li>
</ul>
</div>
CSS:
.Sidebar {
position: fixed;
background-color: #262626;
width: 5%;
height: 100%;
z-index: 1;
}
.Sidebar-Icon {
align-items: center;
font-size: 30px;
}
.Sidebar-Icon .SDIcon {
text-decoration-line: none;
}
.Sidebar-Icon li {
list-style-type: none;
}
ul.Sidebar-Icon {
cursor: pointer;
display: flex;
padding: 0;
flex-direction: column;
align-items: center;
flex: 1;
margin: 0;
height: 100%;
position: relative;
}
.Sidebar-Icon li:first-child{
padding: 20px 0 0 0;
}
.Sidebar-Icon li:first-child,
.Sidebar-Icon li:last-child{
margin-bottom:auto;
}
.sb-i{
color: #999AAA !important; // shadow AAABBB
}
.sb-i i{
width: 100%;
height: auto;
}
.sb-i svg {
width: 100% !important;
height: auto !important;
}
Related
Sorry for the simplicity of this question. This doesnt work by any way, I dont know what else to do.
This image shouldnt be selected? I've tried lot of ways to select it but its not being selected.
I may be making a fool mistake.
HTML
<div class="social-media__banner">
<ul>
<li>
<a href="">
<img id="icon-test" src="images/github.svg" alt="github">
</a>
</li>
<li>
<a href="">
</a>
</li>
<li>
<a href="">
</a>
</li>
</ul>
</div>
CSS
.social-media__banner {
margin-top: 20px;
position: absolute;
top:500px;
left: 0;
width: 100%;
height: 200px;
ul{
left: 0rem;
width: 30px;
display: flex;
padding: 0;
li{
margin: 0 10px;
list-style: none;
font-size: 20px;
padding: 20px 20px;
color: white;
a{
position: relative;
display: block;
width: 50px;
height: 50px;
background-color: white;
color: black;
text-align: center;
border-radius: 50%;
overflow: hidden;
}
}
}
}
#icon-test{
height: 24px;
margin-top: 11px;
}
*I've checked on the inspector tool and it does not even select.
Thanks
If not for the cleanliness alone, why nest all of those selectors? Stick with the basics and you won't go wrong. You are saving yourself having to write .social-media__banner only a few times in your code.
.social-media__banner {
margin-top: 20px;
position: absolute;
top:500px;
left: 0;
width: 100%;
height: 200px;
}
.social-media__banner ul{
left: 0rem;
width: 30px;
display: flex;
padding: 0;
}
.social-media__banner li{
margin: 0 10px;
list-style: none;
font-size: 20px;
padding: 20px 20px;
color: white;
}
.social-media__banner a{
position: relative;
display: block;
width: 50px;
height: 50px;
background-color: white;
color: black;
text-align: center;
border-radius: 50%;
overflow: hidden;
}
#icon-test{
height: 24px;
margin-top: 11px;
}
<div class="social-media__banner">
<ul>
<li>
<a href="">
<img id="icon-test" src="https://miro.medium.com/max/1200/1*mk1-6aYaf_Bes1E3Imhc0A.jpeg" alt="github">
</a>
</li>
<li>
<a href="">
</a>
</li>
<li>
<a href="">
</a>
</li>
</ul>
</div>
I am trying to animate slider up and down on toggle on navbar using javascript but the css transition property is not working on the ul element
Following is my updated codepen https://codepen.io/divya95/pen/vYNdKrz
Code:
<div class="container row">
<nav class="nav">
<a class="logo"><img src="../flexbox/vanderbilt-commodores-1.svg"></a>
<ul class="nav__list nav__list--primary">
<li class="nav__item">
Home
</li>
<li class="nav__item">
About
</li>
<li class="nav__item">
Contact Us
</li>
<li class="nav__item">
Sign In
</li>
<li class="nav__item">
Sign Up
</li>
</ul>
<button class="nav-toggle">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</button>
<!-- <ul class="nav__list nav__list--secondary">
</ul> -->
</nav>
</div>
Css:
.nav-visible {
width: 100%;
text-align: center;
position: fixed;
display: flex;
flex-direction: column;
justify-content: center;
top: 40px;
display: block;
background: #2E323F;
list-style-type: none;
padding: 1em;
/* this is not working */
transition: height 5s ease;
}
Here I used jQuery because it's easier for me but you can make it without it.
notice how i also changed .nav-visible and .nav__list
$(document).ready(function(){
$('.nav-toggle').click(function () {
$(this).toggleClass('is-active');
toggleMenu($(this).hasClass('is-active'));
});
});
function toggleMenu(openMenu) {
let menu = $('.nav__list');
if(openMenu) {
menu.css('height', 'auto');
let nextHeight = menu.height();
menu.css('height', 0);
menu.animate({
'height': nextHeight,
'padding': '1em'
}, 200, function() {
menu.css({
'height': 'auto',
});
});
} else {
menu.css('overflow', 'hidden');
menu.animate({
'height': 0,
'padding': 0
}, 200);
}
}
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: 'Montserrat', sans-serif;
font-size: 1.3125rem;
line-height: 1.6;
color: #222C2A;
}
.container {
max-width: 1200px;
}
.row {
display: flex;
justify-content: space-between;
}
.nav {
display: flex;
justify-content: space-between;
width: 100%;
background: #2E323F;
}
.nav__list {
height: 0;
overflow: hidden;
}
.nav__link {
text-decoration: none;
text-transform: uppercase;
font-size: 1rem;
font-weight: 600;
color: white;
}
.nav__list {
width: 100%;
text-align: center;
position: fixed;
display: flex;
flex-direction: column;
justify-content: center;
top: 40px;
display: block;
background: #2E323F;
list-style-type: none;
padding: 0em;
}
.nav-visible {
padding: 1em;
}
.nav-visible .nav__item {
padding-bottom: 1em;
}
.nav__link {
padding: 1em;
}
.logo {
margin-left: 2.5em;
}
.logo img {
width: 45px;
height: 45px;
margin-left: 1em;
margin-top: 0.5em;
margin-right: 0.5em;
}
.nav-toggle {
width: 2.5rem;
height: 2.5rem;
border-radius: 50%;
margin-top: 0.85em;
margin-right: 0.95em;
}
.bar {
cursor: pointer;
display: block;
height: 2px;
background: #222C2A;
transition: all 0.3s ease-in-out;
}
.bar:nth-child(1) {
-webkit-transform: translateY(-6px);
transform: translateY(-6px);
}
.bar:nth-child(3) {
-webkit-transform: translateY(6px);
transform: translateY(6px);
}
.hamburger-active .bar:nth-child(1) {
-webkit-transform: translateY(2px) rotate(45deg);
transform: translateY(2px) rotate(45deg);
}
.hamburger-active .bar:nth-child(2) {
opacity: 0;
}
.hamburger-active .bar:nth-child(3) {
-webkit-transform: translateY(-2px) rotate(-45deg);
transform: translateY(-2px) rotate(-45deg);
}
#media(min-width: 700px) {
header {
background: #2E323F;
}
.row {
display: flex;
align-items: center;
justify-content: space-between;
}
.nav {
display: flex;
justify-content: space-between;
}
.nav__list {
list-style-type: none;
display: flex;
/* visibility: visible; */
}
.nav__link {
text-decoration: none;
text-transform: uppercase;
font-size: 0.85rem;
margin-right: 0.8em;
}
.nav-toggle {
display: none;
}
.nav__item {
margin-right: 1.5em;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<header>
<div class="container row">
<nav class="nav">
<a class="logo"><img src="../flexbox/vanderbilt-commodores-1.svg"></a>
<ul class="nav__list nav__list--primary">
<li class="nav__item">
Home
</li>
<li class="nav__item">
About
</li>
<li class="nav__item">
Contact Us
</li>
<li class="nav__item">
Sign In
</li>
<li class="nav__item">
Sign Up
</li>
</ul>
<button class="nav-toggle">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</button>
</nav>
</div>
</header>
Why text is not wrapping in IE10?
body{
background: url(http://i.imgur.com/ilgJJ1Q.gif);
margin: 0;
}
ul{
margin: 0;
padding: 0;
list-style: none;
display: flex;
height: 80px;
}
li{
display: flex;
}
ul a {
color: #fff;
display: flex;
-webkit-align-items: center;
align-items: center;
max-width: 240px;
padding: 12px 50px;
align-items: center;
text-transform: uppercase;
text-decoration: none;
}
li img{
border: 0;
margin-right: 10px;
}
li span span {
display: block;
height: 2px;
margin: 7px 0 -7px;
width: 25px;
}
li:last-child{
background: rgba(38, 46, 54, .6);
}
li:nth-child(2){ background: #a15796; }
li:nth-child(3){ background: #b48c4d; }
li:nth-child(4){ background: #3a7d7d; }
<ul class="top-level-tax">
<li>
<a href="#" >
<img src="http://i.imgur.com/SRVh4os.png">
<span>Lorem ipsum dolor<span style="background-color: #38729c;"></span></span>
</a>
</li>
<li>
<a href="#" >
<img src="http://i.imgur.com/rBM2CYr.png">
<span>consectetur adipisicing<span style="background-color: #a05995;"></span></span>
</a>
</li>
<li>
<a href="#" class="" >
<img src="http://i.imgur.com/9dFFuH5.png">
<span>Mollitia harum<span style="background-color: #b38c51;"></span></span>
</a>
</li>
<li>
<a href="#" >
<img src="http://i.imgur.com/7bQ73kd.png">
<span>veritatis ea ipsa<span style="background-color: #3d7d7d;"></span></span>
</a>
</li>
</ul>
https://jsfiddle.net/afelixj/79pybrh9/1/
Add max-width to the span
li span{
display: block;
max-width: 120px;
}
You need to add flex-wrap: wrap; on your <ul> to specify you want it to wrap its content.
I want to align the link text vertically in the <li> list. I tried several ways, but couldn't find the solution. I must keep the percentage height.
A sample version of my code: https://jsfiddle.net/kr0mf4oe/3/
div#html {
height: 500px;
}
div#main {
display: block;
height: 100%;
background-color: blue;
}
ul#list {
height: 100%;
background-color: green;
}
ul#list>li {
height: 20%;
border-width: 2px;
border-bottom: 2px white solid;
}
li>a {
height: 100%;
display: block;
text-align: center;
}
<div id="html">
<div id="main">
<ul id="list">
<li class="leaf1">
text1
</li>
<li class="leaf2">
text2
</li>
<li class="leaf3">
text3
</li>
<li class="leaf4">
text4
</li>
<li class="leaf5">
text5
</li>
</ul>
</div>
</div>
You can use CSS table + table-cell. As table-cell has the vertical-align feature.
ul#list>li {
display: table;
width: 100%;
}
ul#list>li>a {
display: table-cell;
vertical-align: middle;
}
div#html {
height: 500px;
}
div#main {
display: block;
height: 100%;
background-color: blue;
}
ul#list {
height: 100%;
background-color: green;
list-style: none; /*added*/
padding-left: 0; /*added*/
}
ul#list>li {
height: 20%;
border-width: 2px;
border-bottom: 2px white solid;
display: table; /*added*/
width: 100%; /*added*/
}
ul#list>li>a {
height: 100%;
text-align: center;
display: table-cell; /*added*/
vertical-align: middle; /*added*/
}
<div id="html">
<div id="main">
<ul id="list">
<li class="leaf1">
text1
</li>
<li class="leaf2">
text2
</li>
<li class="leaf3">
text3
</li>
<li class="leaf4">
text4
</li>
<li class="leaf5">
text5
</li>
</ul>
</div>
</div>
You can also use the CSS3 flexbox, with justify-content:center for center horizontally, and align-items:center for center vertically.
ul#list>li>a {
display: flex;
justify-content: center;
align-items: center;
}
div#html {
height: 500px;
}
div#main {
display: block;
height: 100%;
background-color: blue;
}
ul#list {
height: 100%;
background-color: green;
list-style: none; /*added*/
padding-left: 0; /*added*/
}
ul#list>li {
height: 20%;
border-width: 2px;
border-bottom: 2px white solid;
}
ul#list>li>a {
height: 100%;
display: flex; /*added*/
justify-content: center; /*added*/
align-items: center; /*added*/
}
<div id="html">
<div id="main">
<ul id="list">
<li class="leaf1">
text1
</li>
<li class="leaf2">
text2
</li>
<li class="leaf3">
text3
</li>
<li class="leaf4">
text4
</li>
<li class="leaf5">
text5
</li>
</ul>
</div>
</div>
If you don't want to use tables, you can also do it like this:
div#html{
height:500px;
}
div#main{
display:block;
height:100%;
background-color:blue;
}
ul#list{
height:100%;
background-color:green;
}
ul#list>li{
height:20%;
border-width: 2px;
border-bottom: 2px white solid;
position: relative; /* new */
}
li>a{
height:100%;
display:block;
text-align:center;
}
li>a>span{ /* new */
position: absolute;
width: 100%;
left: 0;
top: 50%;
-webkit-transform: translateY(-50%);
}
<div id="html">
<div id="main">
<ul id="list">
<li class="leaf1">
<span>text1<br />text1.1</span> <!-- wrap your text in a span -->
</li>
<li class="leaf2">
<span>text2</span>
</li>
<li class="leaf3">
<span>text3</span>
</li>
<li class="leaf4">
<span>text4</span>
</li>
<li class="leaf5">
<span>text5</span>
</li>
</ul>
</div>
</div>
Are you wanting the text to be vertically aligned within the green box that is the list element? If so:
Tell the <li> to display as a table and then you can tell the <a> within it to vertical-align, so split up your CSS for the li>a into 2 tags as so:
li{
height:100%;
width: 100%;
display:table;
text-align:center;
padding-top: 20px;
}
li a {
display: table-cell;
vertical-align: middle;
}
I have created three blocks using the html code as shown below. The "a" tag has the min-height css property because of which it will be displayed as block. I am not able to place the text inside the span tag in the center of "li" tag. Although each text inside the tag is of different length, I want to display them in the center.
<div class="container">
<div class="col-md-12">
<ul id="tabs" class="nav-tabs">
<li class="col-md-4 nav-list">
<a href="#" class="nav-block">
<span class="header">Data</span>
</a>
</li>
<li class="col-md-4 nav-list">
<a href="#" class="nav-block">
<span class="header">Charts</span>
</a>
</li>
<li class="col-md-4 nav-list">
<a href="#" class="nav-block">
<span class="header">Reports</span>
</a>
</li>
</div>
</div>
CSS:
.container ul {
list-style: none outside none;
}
li {
display: list-item;
}
.col-md-4 {
width: 33%;
}
.nav-block {
background-color: #FFA500;
display: block;
min-height: 70px;
position: relative;
}
.container .nav-block .header {
color: #FFFFFF;
font-size: 2em;
font-weight: bold;
left: 20%;
padding: 5px;
position: relative;
text-align: center;
top: 21%;
}
Please let me know where I am going wrong
just changed the css to center the texts, check in the fiddle
.nav-block {
background-color: #FFA500;
display: block;
min-height: 70px;
position: relative;
text-align: center;
}
.container .nav-block .header {
color: #FFFFFF;
font-size: 2em;
font-weight: bold;
padding: 5px;
position: relative;
text-align: center;
top: 21%;
}
You should set the text-align:center; on the li{}
And delete the position:relative; on .container .nav-block .header {
DEMO
With editting my sugestions you have a shorter css, because you can delete the unaccecary things. Like here.
.container .nav-block .header {
color: #FFFFFF;
font-size: 2em;
font-weight: bold;
padding: 5px;
}
DEMO 2 (same as the other but less css)
Try this below css.
.nav-block {
background-color: #FFA500;
display: block;
min-height: 70px;
position: relative;
text-align: center; /*New Edit*/
}
.container .nav-block .header {
color: #FFFFFF;
font-size: 2em;
font-weight: bold;
/*left: 20%; - Remove*/
padding: 5px;
position: relative;
text-align: center;
top: 21%;
}
just add text-align:center; to .nav-tabs or .nav-block
You aren't closing your <ul> tag.
I hope this is what you want ->
DEMO
HTML
<div class="container">
<div class="col-md-12">
<ul id="tabs" class="nav-tabs">
<li class="col-md-4 nav-list">
<a href="#" class="nav-block">
<span class="header">Data</span>
</a>
</li>
<li class="col-md-4 nav-list">
<a href="#" class="nav-block">
<span class="header">Charts</span>
</a>
</li>
<li class="col-md-4 nav-list">
<a href="#" class="nav-block">
<span class="header">Reports</span>
</a>
</li>
<!--closing the ul tag-->
</ul>
</div>
</div>
CSS
.container ul {
list-style: none outside none;
}
li {
display: list-item;
}
.col-md-4 {
width: 33%;
}
.nav-block {
background-color: #FFA500;
display: block;
min-height: 70px;
position: relative;
text-align:center; /*aligning the text center*/
line-height:60px; /*this gives vertical alignment to your element*/
}
.container .nav-block .header {
color: #FFFFFF;
font-size: 2em;
font-weight: bold;
left: 0; /*removed the defined 20% to center you text inside anchor <a> tags*/
padding: 5px;
position: relative;
text-align: center;
top: 21%;
}