Working on a vertical navigation menu which came out great but running into issues with navigation menu filling the whole page (viewport).
The menu as it is ends at the middle of the page. (image)
enter image description here
Not sure what the issue is but hoping to get some clues on where I went wrong?
Thanks in advance.
HTML
<div class="header-social">
<div class="hamburger-vertical">
<div class="menu-icon">
<span class="line"></span>
<span class="line"></span>
<span class="line"></span>
</div>
</div>
<nav class="header-nav-secondary">
<ul>
<li class="brands">BRANDS</li>
</ul>
</nav>
</div>
CSS
/* NAV BAR CSS*/
.header-social {
float: right;
transform: rotate(-90deg) translateY(-100%);
transform-origin: top right;
background: #7D522A66;
height: 75px;
width: 100%;
z-index: 2000;
position: absolute;
}
.hamburger-vertical{
border: solid 1px;
float: right;
width: 117px;
height: 100%;
background-color: #CAA571;
}
.menu-icon{
transform: rotate(90deg);
position: fixed;
padding: 1px 5px 0 55px;
}
.menu-icon > .line {
background-color: #292929;
height: 1.5px;
display: block;
width: 35px;
}
.menu-icon > .line + .line {
margin-top: 8px;
}
.header-nav-secondary{
float: right;
}
li.brands{
transform: rotate(180deg);
font-family: Montserrat, sans-serif;
text-transform: capitalize;
color: white;
padding-left: 40px;
letter-spacing: 2px;
display: inline-block;
padding-bottom: 5px;
}
Assuming that 'header-nav-secondary' is intended to be at 100% height of the viewport: Have you tried setting it's height to 100vh? The vh unit is the viewport's height so setting it to 100vh should make it 100% of the viewport's height.
.header-nav-secondary{
float: right;
height: 100vh;
}
Related
I am creating rows of objects that are currently in an HTML table as separate elements so that I have more flexibility when making the page responsive. However, I am unable to get the span text elements to center with the status div or button at all. The span text seems to have a larger bottom 'padding' than the other elements and for the life of me I can't figure out why.
I have to use floats for alignment (to my knowledge), unfortunately, as the website must fully support IE10+, otherwise I would use something like flex. Most of the things I've looked at and researched online deal with one line of text another element and many suggest editing the line height which seems to me like it wouldn't be the best solution for this case.
The codepen for all the code is here: https://codepen.io/stevennava/pen/WNrzzKo
and here is the code (per StackOverflow standards):
#outer-border {
border: 1px solid black;
border-radius: 5px;
padding: 1.3em 0;
position: relative;
}
#centered-container {
margin: 0;
padding: auto;
position: absolute;
top: 50%;
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
#status {
position: relative;
border: 1px solid lightgrey;
border-radius: 8px;
padding: 0 .2em 0 .2em
}
#status-message {
float: left;
margin-left: 1.2em;
}
#status-circle {
width: 12px;
height: 12px;
background-color: orange;
border-radius: 50%;
float: left;
margin: 0;
position: absolute;
top: 50%;
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
#button {
height: 1.5em;
width: 1.5em;
text-align: center;
}
.order-element {
padding: 0;
float: left;
margin-left: 15px;
}
.clearfix {
overflow: auto;
}
.clearfix::after {
content: "";
clear: both;
display: table;
}
<div id="outer-border" class="clearfix">
<div id="centered-container" class="clearfix">
<span name="user-name" class="order-element">John Smith</span>
<div id="status" class="order-element">
<div id="status-circle" class=""></div>
<span id="status-message" class="">Complete<span>
</div>
<div class="clearfix">
<span name="order-number" class="order-element">123456</span>
<span name="order-amount" class="order-element">$35.45</span>
<span name="fulfillment-date" class="order-element">07/07/2020 07:00 PM</span>
<button id="button" class="order-element">...</button>
</div>
</div>
and this is this the result looks like:
Two things, the height of the button is causing the .clearfix div's height to stretch, and the border on the #status is causing it's height to stretch.
If you don't want to completely change this up, you can add padding to match the thickness of the border on the spans, and set the button height to auto.
#outer-border {
border: 1px solid black;
border-radius: 5px;
padding: 1.3em 0;
position: relative;
}
#centered-container {
margin: 0;
padding: auto;
position: absolute;
top: 50%;
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
#status {
position: relative;
border: 1px solid lightgrey;
border-radius: 8px;
padding: 0 .2em 0 .2em
}
#status-message {
float: left;
margin-left: 1.2em;
}
#status-circle {
width: 12px;
height: 12px;
background-color: orange;
border-radius: 50%;
float: left;
margin: 0;
position: absolute;
top: 50%;
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
#button {
height: auto;
width: 1.5em;
text-align: center;
}
.order-element {
padding: 0;
float: left;
margin-left: 15px;
}
.clearfix {
overflow: auto;
}
.clearfix::after {
content: "";
clear: both;
display: table;
}
.pad-1 {
padding-top: 1px;
padding-bottom: 1px;
}
<div id="outer-border" class="clearfix">
<div id="centered-container" class="clearfix">
<span name="user-name" class="order-element pad-1">John Smith</span>
<div id="status" class="order-element">
<div id="status-circle" class=""></div>
<span id="status-message" class="">Complete<span>
</div>
<div class="clearfix">
<span name="order-number" class="order-element pad-1">123456</span>
<span name="order-amount" class="order-element pad-1">$35.45</span>
<span name="fulfillment-date" class="order-element pad-1">07/07/2020 07:00 PM</span>
<button id="button" class="order-element">...</button>
</div>
</div>
I am trying to get this to happen.
what I want
So far, I don't know how to overlap one img-div with another text-div and keep white space on the top of the text-div. You will see. What I have right now is:
<div id="some">
<img src="photos/some.png">
<div id="box">
<p>Proudly seeking</p>
<h2>some Cofefe</h2>
<button id="shopNow" class="button">Shop</button>
</div>
</div>
With some CSS that doesn't make it very appealing: what it looks like
#some{
margin-top: 20px;
background-color: red;
}
#some img{
width: 30%;
float: left;
}
#box{
padding-top: 220px;
margin-right: 40px;
font-family: "Eusthalia";
text-align: right;
}
#box p{
margin-right: 32%
}
h2 {
font-size: 2.6em;
}
button {
border: none;
font-family: "Eusthalia";
font-size: 15px;
background-color: #300c06;
color: #eadfc0;
padding: 2px 10px;
}
I am wondering if my whole approach with divs is wrong. I was researching and I found that right:0; doesn't work and stuff like that. How do I get a border to overlap behind the image? How do I give it a width and a height but make it push to the right?
Do I have to make the main div width 100% and then give the img a width 30% and the colored filled in text box 70%? But how would I have the box behind the img?
Drearo, I think you're doing fine with div tags. You just may need a bit more of them to help things along.
I would suggest the divs be position: absolute with the image in one of those. The box of text needs it too. Aside from that, a little CSS would get you the positioning you want. See here:
<div id="some">
<div class="my_img">
<img src="photos/some.jpg" />
</div>
<div id="box">
<p>Proudly seeking</p>
<h2>some Cofefe</h2>
<button id="shopNow" class="button">Shop</button>
</div>
</div>
css:
#some{
margin-top: 20px;
height: 100vh;
width: 100vw;
border: 1px solid #000;
position: relative;
}
.my_img {
position: absolute;
top: 5em;
left: 5em;
z-index: 200;
}
.my_img img {
width: 200px;
}
#box{
position: absolute;
top: 10em;
left: 10em;
transition: translate( -50%, -50%);
font-family: "Eusthalia";
text-align: right;
background: red;
min-width: 60%;
padding-right: 2em;
}
#box p{
margin-right: 32%
}
h2 {
font-size: 2.6em;
}
button {
border: none;
font-family: "Eusthalia";
font-size: 15px;
background-color: #300c06;
color: #eadfc0;
padding: 2px 10px;
}
https://jsfiddle.net/5k94j73p/
I am making website in html and css and I have a problem. In my css file I made id "full" which set wooden background after sidebar and it should continue on all page. In my class "picture" I made 80% width white panel - so there should be 80% white background in the middle and 10% edges should be wooden. It works correctly untill my article section, where I added some images of pizzeria. Immediately there is no wooden edges, only white. I don´t understand because my "full" id and "picture" class continue untill end of the body. Could somebody see where is error please?
Image showing error
* {
padding: 0;
margin: 0;
border: 0;
}
.container {
margin: auto;
overflow: hidden;
width: 100%;
}
#full {
background-image: url("http://newallpaper.com/wp-content/uploads/2014/01/Dark-Wood-620x387.jpg");
}
.picture {
margin: auto;
width: 80%;
background: white;
}
#pizzaObrazok {
background-image: url("img/pizzaCompleted.png");
width: 100%;
height: 210px;
margin: 0px;
}
nav {
float: left;
margin-left: 2px;
width: 100%;
height: 32px;
}
ul {
float: left
}
li {
display: inline;
border: 4px solid black;
font-size: 24px;
padding: 10px 64px;
background-color: #990000;
color: #ffffff;
}
li a {
color: #ffffff;
text-decoration: none;
padding-top: 8px;
padding-bottom: 5px;
vertical-align: middle;
}
#imgPizza {
width: 59%;
height: 270px;
padding-left: 190px;
padding-top: 30px;
padding-bottom: 30px;
}
article p {
font-size: 120%;
font-family: fantasy;
text-align: center;
margin-right: 160px;
}
#imgPizza2 {
width: 30%;
height: 270px;
position: absolute;
transform: rotate(345deg);
margin-top: 100px;
margin-left: 50px;
border: 6px solid red;
}
#imgPizza3 {
width: 30%;
height: 270px;
position: absolute;
margin-left: 390px;
margin-top: 100px;
transform: rotate(15deg);
border: 6px solid red;
}
#phone {
border: 2px solid black;
margin-top: 150px;
margin-right: 180px;
padding: 5px;
position: absolute;
display: inline;
text-align: center;
background: #ff4d4d;
}
<header>
<div id="pizzaObrazok">
</div>
</header>
<div id="full">
<section id="navigation">
<div class="container">
<nav>
<ul>
<li>ÚVOD</li>
<li>FOTO</li>
<li>JEDÁLNY LÍSTOK</li>
<li>KDE NÁS NÁJDETE</li>
<li>NÁZORY</li>
</ul>
</nav>
</div>
 
</section>
<div class="picture">
<img id="imgPizza" src="img/pizzacheese.jpg">
<aside id="phone">
<h2>Telefónne číslo:</h2>
<h2> 0905 741 963</h2>
</aside>
</div>
 
<div class="picture">
<article>
<p>U nás dostanete najchutnejšiu pizzu z výlučne kvalitných surovín</p>
<img id="imgPizza2" src="https://cdn.vox-cdn.com/uploads/chorus_image/image/50289897/pizzeria_otto.0.0.jpg">
<img id="imgPizza3" src="https://media-cdn.tripadvisor.com/media/photo-s/09/bc/74/79/pizzeria-du-drugstore.jpg">
</article>
</div>
</div>
You have your elements "#imgPizza2" and "#imgPizza3" whit position absolute outside your "#full" wrapper. You can do various things to achive the effect you are looking for but depends of many others things.
I think the simpliest way is to put your background image in to the body and not in the warpper "#full" or change the postion of your images among others.
body {
background-image: url("http://newallpaper.com/wp-content/uploads/2014/01/Dark-Wood-620x387.jpg");
}
It looks like the wood background is 620 x 387, so my first thought is that it is big enough to cover the first section but not the articles. Maybe add background-repeat: repeat-y; to your #full class and see if the wood border spreads further down the page.
I'm trying to create a div, and then inside the div put the date on the left, and two icons on the right. Both should be vertically centered, have some margin to the edge, and margin between other elements in the parent div. But right now when I run it, the icons end up in strange positions, often clipping out of the div.
.c-project-bar {
width: 355px;
height: 30px;
display: table;
padding: 0px 10px;
background-color: #ffffff;
}
.c-project-date {
display: table-cell;
vertical-align: middle;
color: #828282;
font-size: 14px
}
.c-project-github-icon {
margin-left: 10px;
background-color: #000000;
height: 25px;
width: 25px;
float: right;
vertical-align: middle;
display: table-cell;
}
<div class="c-project-bar">
<p class="c-project-date">Aug, 2017</p>
<span class="c-project-github-icon"></span>
<span class="c-project-github-icon"></span>
</div>
https://jsfiddle.net/enyzhxyz/
Edit:
Everyone's answers are awesome, it seemed a major issue was the fact that the was inheriting { margin: 0px; }, and it was throwing a wrench in everyone's solutions. I solved this by including a margin: initial, before using any margin style later, so it first removed { margin: 0px; } then added the one I wanted.
When you give float: right you cannot vertically centre. Instead, use the inline-block technique:
.c-project-bar {
width: 355px;
padding: 0px 10px;
background: #ccf;
}
.c-project-date, .c-project-icons {
display: inline-block;
width: 48%;
vertical-align: middle;
}
.c-project-icons {
text-align: right;
}
.c-project-github-icon {
margin-left: 10px;
background-color: #000000;
height: 25px;
width:25px;
display: inline-block;
vertical-align: middle;
}
<div class="c-project-bar">
<p class="c-project-date">Aug, 2017</p>
<div class="c-project-icons">
<span class="c-project-github-icon"></span>
<span class="c-project-github-icon"></span>
</div>
</div>
I would have suggested you the transform and position centering technique, but it would be a too much of overkill for this solution. I have given some background colour to see it is perfectly vertical align middle. Although it uses slightly extra markup, this would be the right way that works on browsers that don't support flexbox too.
Here is a solution using css flexbox.
body {
background-color: #696969;
}
.c-project-bar {
display:flex;
align-items: center;
justify-content: space-between;
width: 355px;
height: 30px;
padding: 0px 10px;
background-color: #ffffff;
}
.c-project-date {
color: #828282;
font-size: 14px
}
.c-project-github-icon {
margin-left: 10px;
background-color: #000000;
height: 25px;
width:25px;
float: right;
}
<div class="c-project-bar">
<p class="c-project-date">Aug, 2017</p>
<div>
<span class="c-project-github-icon"></span>
<span class="c-project-github-icon"></span>
</div>
</div>
Another way to achieve this could be to use transform.
position: relative;
top: 50%;
transform: translateY(-50%);
.c-project-bar {
width: 355px;
height: 30px;
padding: 0px 10px;
background-color: #ccc;
}
.c-project-date {
margin: 0;
position: relative;
top: 50%;
transform: translateY(-50%);
float: left;
color: #828282;
font-size: 14px
}
.c-project-github-icon {
margin-left: 10px;
background-color: #000000;
height: 25px;
width:25px;
float: right;
position: relative;
top: 50%;
transform: translateY(-50%);
}
<div class="c-project-bar">
<p class="c-project-date">Aug, 2017</p>
<span class="c-project-github-icon"></span>
<span class="c-project-github-icon"></span>
</div>
You can do it easily with display: flexbox.
.c-project-bar {
display: flex; // power
align-items: center; // aligning
width: 355px;
height: 30px;
padding: 0px 10px;
background-color: #ffffff;
}
.c-project-date {
margin-right: auto; // let's push other stuff to right side
color: #828282;
font-size: 14px
}
.c-project-github-icon {
margin-left: 10px;
background-color: #000000;
height: 25px;
width:25px;
}
Fixed jsfiddle
I'm trying to have a div float to the right however when applying float:right and making the page size smaller with the browser the div goes under the previous div.
https://jsfiddle.net/Crystalwolf/bku2f08c/1/
HTML
<div id="container">
<div id="navbar-container">
<div id="mainlogo">
</div>
<div id="sublogo">
This is a subtitle test
</div>
<div id="navbutton-container">
<div class="navbutton navcurrent">
Home
</div>
<div class="navbutton">
About
</div>
<div class="navbutton">
Web Design
</div>
<div class="navbutton">
Programming
</div>
<div class="navbutton">
Graphic Design
</div>
<div class="navbutton">
Contact
</div>
</div>
</div>
<div id="carousel">
</div>
</div>
CSS
#container {
width: 100%;
height: 100%;
}
#navbar-container {
position: fixed;
background-color: white;
width: 100%;
height: 100px;
padding: 15px;
color: white;
padding-left: 60px;
margin-left: auto;
margin-right: auto;
padding-left: 50px;
padding-right: 50px;
min-width: 1200px;
overflow: hidden;
white-space: nowrap;
}
#mainlogo {
color: #373c40;
font-size: 50px;
font-weight: 700;
text-transform: uppercase;
position: relative;
float: left;
display: inline-block;
padding-left:50px;
}
#sublogo {
color: #373c40;
font-size: 15px;
font-weight: 700;
text-transform: uppercase;
position: relative;
float: left;
padding: 25px;
display: inline-block;
}
#carousel {
background-image: url("http://3nacu.com/unique/images/stars.png");
width: 100%;
height: 500px;
}
#navbutton-container {
margin-top: 10px;
background-color: white;
height: 50px;
padding-left: 50px;
float: right; //THIS SPECIFIC FLOAT RIGHT
display: inline-block;
padding-right:50px;
}
.navbutton {
display: inline-block;
vertical-align: top;
height: 50px;
padding: 15px;
padding-left: 20px;
padding-right: 20px;
text-decoration: none;
color: #373c40;
-o-transition: .5s;
-ms-transition: .5s;
-moz-transition: .5s;
-webkit-transition: .5s;
transition: .5s;
cursor: pointer;
text-transform: uppercase;
font-weight: 700;
}
.navbutton:hover {
background-color: #373c40;
color: white;
}
.navcurrent {
background-color: #B39EB5;
color: white;
}
e.g Have the browser at 1920 on the result and it's all on one line. As soon as you make it a considerable amount shorter it proceeds to just go under the previous div instead of just enabling a horizontal scroll bar.
This is expected behavior, floated elements will break if there's not enough room for them inside the container. If you want a scrollable overflow instead, you need to give the container a fixed width (e.g. 1200px instead of 100%) large enough to fit all the floated elements.