I have been struggling with this for quite some time now. Apparently using % width and height is not enough?
Right now I have fixed 100px width and height and border radius is half of it so it will make it look round. Line height is set to 100px so text would display vertically in the middle of those circles. I have no idea how to vertically center text in another way...
How do I make this menu responsive so it would become smaller as the screen size changes?
HTML:
<div id="menu">
<ul>
<li>Link</li>
<li>Link</li>
<li>Link</li>
<li>Link</li>
<li>Link</li>
</ul>
</div>
CSS:
#menu ul {list-style-type: none; padding: 0; margin: 0;}
#menu li {display: inline; float: left;}
#menu a {
display: block;
width: 100px;
height: 100px;
-moz-border-radius: 50px;
border-radius: 50px;
border: 1px #a2a2a2 solid;
text-transform: uppercase;
text-decoration: none;
font-size: 1em;
text-align: center;
line-height: 100px;
margin: 5%;
}
If you want true 'responsiveness' you can use the vw units which are directly related to the viewport width.
Jsfiddle Demo
Support isn't bad: CanIUse.com
#menu ul {
list-style-type: none;
padding: 0;
margin: 0;
}
#menu li {
display: inline-block;
}
#menu a {
display: block;
width: 15vw;
height: 15vw;
border-radius: 50%;
border: 1px #a2a2a2 solid;
text-transform: uppercase;
text-decoration: none;
font-size: 4vw;
text-align: center;
line-height: 15vw;
margin: 5%;
}
<div id="menu">
<ul>
<li>Link
</li>
<li>Link
</li>
<li>Link
</li>
<li>Link
</li>
<li>Link
</li>
</ul>
</div>
Related
I am new in programming and I have a simple question: I want to make the words in this navigation bar be further from each other.
ul{
list-style-type: none;
margin: 0px;
padding: 0px;
width: 100%;
overflow: hidden;
top: 0;
position: fixed;
}
li{
float: right;
transform: translateX(-300px);
transform: translateY(-30px;);
}
li a{
display: block;
text-align:center;
padding: 12px 16px;
text-decoration: none;
color: #fff ;
font-size: 37px;
font-family: 'Alegreya', serif;
}
<div class="header">
<header class="title">CSS Tricks</header>
<ul>
<li>
Home
</li>
<li>
Contact
</li>
<li>
About
</li>
<li>
News
</li>
</ul>
</div>
I don't see the point of using transform.. use display: flex instead of float: right and if you would like to have it on the right side, do justify-content: flex-end. About your question, if it is having space between the <a> use the margin: 0 30px or if your meant between letters, do letter-spacing: 5px like in the example below..
ul {
list-style-type: none;
margin: 0;
padding: 0;
width: 100%;
overflow: hidden;
top: 0;
position: fixed;
display: flex;
}
li a {
display: block;
padding: 12px 0;
margin: 0 30px;
text-decoration: none;
color: #000;
font-size: 3em;
font-family: 'Alegreya', serif;
letter-spacing: 5px;
}
<div class="header">
<ul>
<li>Home</li>
<li>Contact</li>
<li>About</li>
<li>News</li>
</ul>
</div>
you have a typo on this property transform: translateY(-30px;);
it should be without ; after value -30px
👇
transform: translateY(-30px);
Currently you've got a padding of 16px on the sides of your hyperlink tags. Because it's on both the left and right sides, that adds up to 32px between the text of each. Increasing that value will increase the space between the links.
Adding padding or margin to the <li> elements would also work.
Is there a better way of making footer menu for responsive? rather than duplicating and display: none; in the css?
Here are my attempts:
<header class="row">
<div class="container">
<div class="col-12 columns">
<img src="images/logo.png" alt="" class="logo">
Navigation
<nav role="primary" >
<ul id="nav">
<li>Home</li>
<li>About Me</li>
<li>Blog</li>
<li>Contact</li>
</ul>
</nav>
</div>
</div>
</header>
Footer nav. Commented out the nav for the purpose of this question.
<nav role="secondary_menu">
<!-- <ul id="nav2">
<li>Home</li>
<li>About Me</li>
<li>Blog</li>
<li>Contact</li>
</ul>
</nav> -->
<footer id="footer">
<div class="container">
<p>Created by: </p>
</div>
</footer>
CSS:
a.nav-link{
float: right;
text-align: center;
text-decoration: none;
background: #808080;
color:#fff;
font-weight: bold;
padding:1em 2em;
margin-top: 1.5em;
}
nav[role="primary"] ul{
list-style-type: none;
position: absolute;
bottom: 0;
left: 0;
width: 100%;
}
nav[role="primary"] ul li a{
text-decoration: none;
font-weight: bold;
background: #3c3c3c;
display: block;
padding:.75em;
color:#ccc;
border-bottom: 1px solid #ccc;
}
.container .columns{
float: left;
margin: 0 0 0 0;
padding-right: 1em;
padding-left: 1em;
}
.row{
float: left;
clear: both;
width: 100%;
}
.columns.col-12 { width: 100%; }
So the codes above shows when the screen is below 600px however this way it pushes the footer the menu rather than at the bottom, Sure I positioned the footer absolute but it just sits above the menu rather than under it. So I made another attempt which I duplicated the nav and just hiding the when its below 600px.
position:none
position:absolute
Trying to achieve without duplicating and remove whitespace
I saw your main nav was set to position: absolute. I would suggest looking at CSS templates to see how they structure things like footers. For example, http://bootswatch.com/default/ Try this CSS:
a.nav-link{
float: right;
text-align: center;
text-decoration: none;
background: #808080;
color:#fff;
font-weight: bold;
padding:1em 2em;
margin-top: 1.5em;
}
nav[role="primary"] ul{
list-style-type: none;
bottom: 0;
left: 0;
width: 100%;
}
nav[role="primary"] ul li a{
text-decoration: none;
font-weight: bold;
background: #3c3c3c;
display: block;
padding:.75em;
color:#ccc;
border-bottom: 1px solid #ccc;
}
.container .columns{
margin: 0 0 0 0;
padding-right: 1em;
padding-left: 1em;
}
.row{
margin-right: -15px;
margin-left: -15px;
clear: both;
width: 100%;
}
.columns.col-12 { width: 100%; }
I am trying to align the navigation bar to the left of the container which is 950px wide, but it's still showing the margin on the left side. How do I align it to the left completely without specifying the left margin in negative?
JSFiddle
HTML5 code
<div class="nav-holder">
<nav class="container">
<ul>
<li class="active">Home</li>
<li>Features</li>
<li>Programs</li>
<li>Marketing tools</li>
<li>About Us</li>
<li>Faq</li>
<li>Contact us</li>
<li>Sign Up</li>
</ul>
</nav>
</div><!-- nav holder -->
CSS
body{margin:0}
ul {
list-style: none;
}
.container {
width: 950px;
margin: 0 auto;
}
.nav-holder {
overflow: hidden;
background: url('images/nav-bg.jpg') repeat-x;
}
.nav-holder nav {
overflow: hidden;
margin-top: -3px;
margin-bottom: 12px;
}
.nav-holder li {
float: left;
}
.nav-holder li a {
display: block;
text-decoration: none;
color: #ff0202;
padding: 4px 23px;
text-transform: uppercase;
font-size: 14px;
text-shadow: 1px 1px 1px #FFF;
}
.nav-holder li a:hover,.nav-holder li.active a {
background: rgba(162, 162, 162, 0.7);
}
If I am not wrong, all lists (ul and ol) have default indents associated with them. Try adding a padding: 0; to your CSS rule for ul like below.
ul {
padding: 0;
list-style: none;
}
Use padding-left
http://jsfiddle.net/fDJA8/4/
ul {
padding-left : 0px;
}
I have following code:
<div class="settingsMenu" style="top: 135px; left: 149px; display: block;">
<ul>
<li class="download" onclick="downTemplate('template1')">Download</li>
<li class="delete" onclick="showConfirmationDialog ($(this))">
Delete
<div class="deleteItemConfirmation">
<div class="confirmationText">Are you sure?</div>
<div class="buttons"><button onclick="deleteTemplate ('template1')">Yes</button> <button onclick="hideConfirmationDialog();">No</button></div>
</div>
</li>
<li class="info">Info</li>
</ul>
</div>
CSS:
.settingsMenu{
position: absolute;
top: 0;
left: 0;
display: none;
background-color: #FFFFFF;
border: 1px solid #b5044a;
border-radius: 5px;
width: 150px;
padding: 10px 0;
margin: 0;
z-index: 200;
}
.settingsMenu ul{
list-style-type: none;
width: 100%;
margin: 0px;
padding: 0;
}
.settingsMenu ul li {
color: #000000;
cursor: pointer;
float: left;
font-size: 14px;
font-weight: normal;
font-family: Arial;
height: 18px;
max-width: 100px;
margin: 5px 20px;
padding: 0;
display: block;
padding-left: 30px;
}
.settingsMenu ul li.edit{
background: url("../img/edit-context-menu-icon.svg") no-repeat scroll center left white;
}
.settingsMenu ul li.delete{
background: url("../img/delete-context-menu-icon.svg") no-repeat scroll center left white;
}
.settingsMenu ul li.info{
background: url("../img/info-context-menu-icon.svg") no-repeat scroll center left white;
}
Problem is: while div.deleteItemConfirmation has "display: none;" everything is displaying correctly, when it`s display property becomes "display: block;" strange space appears before text of
<li>Delete</li>
Try changing
<li class="delete" onclick="showConfirmationDialog ($(this))">
Delete
To
<li class="delete" onclick="showConfirmationDialog ($(this))">Delete
Could this help you out:
<ul>
<li>
one</li><li>
two</li><li>
three</li>
</ul>
or
<ul>
<li>one</li
><li>two</li
><li>three</li>
</ul>
or with comments...
<ul>
<li>one</li><!--
--><li>two</li><!--
--><li>three</li>
</ul>
I took the idea from http://css-tricks.com/fighting-the-space-between-inline-block-elements/ and helped me in a few similar situations.
In the image above, you can see that -its not perfect- all the <ul> elements have all the same size, and the <li> items no, but they are centered in the <ul> no matter what size is (always assuming that will be smaller)
how can i do this?
ul{ width:160px; }
li{ width:auto; margin:5px auto;}
is not working..
-Image edited with texts-
I don't really understand what you're trying to say with your images, but here's how to make something that looks like them.
See: http://jsfiddle.net/thirtydot/wGpPc/
HTML:
<div class="listContainer">
<ul>
<li>Item 1</li>
<li>Item 2</li>
..
</ul>
</div>
CSS:
.listContainer {
width: 160px;
background: #ccc;
border: 1px solid #444;
float: left;
text-align: center;
margin-right: 9px
}
.listContainer ul {
list-style: none;
margin: 0;
padding: 0;
display: inline-block;
vertical-align: top;
text-align: left;
background: #f0f;
/* for ie6/7 */
*display: inline;
zoom: 1
}
li {
margin: 5px 0;
background: #fff
}