Wedge shaped menu - html

I've been digging into how to create a wedge shaped menu and came across the following stackoverflow post: Diagonal Wedge Shaped CSS - Edge to Edge Centered in Browser
I've re-purposed the example image Varazi drew up to better explain my own situation (please excuse the old writing on it). I've added 2 menu items, home and contact, to show what I'm trying.
The code I have been playing around with (found from the above link).
HTML
<div class="shape">
<div class="top"></div>
<div class="bottom"></div>
</div>
CSS
.shape {
width:400px;
margin:0 auto;
}
.top {
height:0;
border-width:0 0 150px 400px;
border-style:solid;
border-color:transparent #d71f55 #d71f55 transparent;
}
.bottom {
height: 50px;
background-color:#d71f55;
}
/* Support transparent border colors in IE6. */
* html .top {
filter:chroma(color=#123456);
border-top-color:#123456;
border-left-color:#123456;
}
Update: After playing quite a lot with it, really fun challenge I must say, I have finally gotten it exactly the way I needed it to be with the helpful tip by Talkingrock (thanks man!). My remaining challenge would be showing the .sub-menu inside an overflow: hidden element (#masthead), but it's not overly important as I can have the links plastered on the homepage in the relevant content sections.
Hope the below code helps a poor soul out, such as myself, who needed help. Enjoy! :)
HTML (I'm using WordPress/Bootstrap)
<header id="masthead" class="site-header" role="banner">
<nav id="site-navigation" class="navbar navbar-default" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="http://demo.dev/" title="demo" rel="home">
<img width="159" height="134" src="http://demo.dev/wp-content/uploads/2014/10/logo.png" class="img-responsive" alt="logo">
</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul id="menu-main-menu" class="nav navbar-nav pull-right">
<li>Home</li>
<li>About Us</li>
<li>Services
<ul class="sub-menu">
<li>Industrial Electrical</li>
<li>Commercial Electrical</li>
<li>Domestic Electrical</li>
</ul>
</li>
<li>Contact</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
</header>
CSS (using Less)
/* --- header */
#masthead {
overflow: hidden;
position: relative;
bottom: 50px; height: 200px;
background: red;
transform: skew(0deg, -3deg);
}
/* --- main navigation */
#site-navigation {
position: relative;
bottom: -50px;
height: 100%;
margin-bottom: 0;
border-radius: 0;
background: none;
border: none;
transform: skew(0deg, 3deg);
.container,
.navbar-collapse {
height: 100% !important;
}
.nav {
height: 100%;
&>li {
height: 100%;
&>a {
height: 100%;
padding: 80px 15px 0;
color: #fff;
}
&.current-menu-item,
&:hover {
&>a {
background-color: #tree-poppy;
}
}
}
}
}
Update2: Just wanted to quickly mention you can also attach the wedge part to an existing element easily without using any additional elements as well!
CSS
#masthead:after {
content: "";
position: absolute;
top: -45px; left: 0;
z-index: -1;
width: 100%; height: 80px;
background-color: red;
transform: skew(0deg, -3deg);
}

Here's what I came up with:
The HTML:
<header>
<nav>
Home
Contact
About
</nav>
</header>
The CSS:
header {
overflow: hidden;
margin-top: -550px;
height: 850px;
margin-bottom: -50px;
}
nav {
width: 120%;
margin: 0 -10%;
transform: rotate(-12deg);
background: red;
padding: 0 10%;
overflow: hidden;
}
nav a {
color: #fff;
text-decoration: none;
display: block;
float: left;
transform: rotate(12deg);
background: purple;
padding-top: 500px;
padding-bottom: 1000px;
margin-bottom: -900px;
text-align: center;
width: 80px;
position: relative;
}
.link-1 {
top: -36px;
}
.link-2 {
top: -18px;
}
Here's a working example: http://codepen.io/btpoe/pen/GavLk
Please note that this would not work in IE8 or less and would need some sort of fallback.

Related

How to add content and icons to the right side in top navbar in vue.js?

I developed one top navbar which is fixed at the top , i am trying to add right side icons and some content into the top navbar [like this]1with two icons and below the content like profile and cart that must be inside the right side top navbar , i am trying to fix that but it's not happening please help me to fix this issue
.
Dashboard.vue
<template>
<div class="main">
<nav class="navbar navbar-default navbar-fixed-top">
<div class="navbar-header">
<img src="../assets/education.png" alt="notFound" />
</div>
<ul class="nav navbar-nav">
<li>
<p>Bookstore</p>
</li>
</ul>
<div class="input-group">
<i class="fas fa-search"></i>
<div class="form-outline">
<input type="search" class="form-control" placeholder='search...' />
</div>
</div>
<ul class="nav navbar-nav navbar-right">
<li><a> <i class="far fa-user"></i></a></li>
<p>profile</p>
<li><a><i class="fas fa-cart-plus"></i></a></li>
<p>cart</p>
</ul>
</nav>
</div>
</template>
<style lang="scss" scoped>
#import "colors";
.navbar-default {
background: $redish_brown;
height: 60px;
}
li p {
margin-top: 5px;
margin-left: -1250px;
width: 91px;
height: 26px;
text-align: left;
font: normal normal normal 18px/26px Roboto;
letter-spacing: 0px;
color: $pale_white;
text-transform: capitalize;
opacity: 1;
}
img {
background: transparent 0% 0% no-repeat padding-box;
opacity: 1;
width: 31px;
height: 24px;
margin-top: -12px;
margin-left: 194px;
}
.input-group{
margin-left:345px;
}
input[type="search"]{
width: 490px;
height: 33px;
margin-top:-40px;
background: #FCFCFC 0% 0% no-repeat padding-box;
border-radius: 3px;
margin-left:3px;
opacity: 1;
}
// .fa-user{
// margin-left:1064px;
// width: 31px;
// height: 36px;
// opacity: 1;
// margin-top:-25%;
// }
.input-group {
display: flex;
align-items: center; // to center the icon vertically
}
.input-group .fas {
position: absolute;
margin-left: 8px;
}
.fa-search{
margin-top:-40px;
opacity: 1;
}
.input-group input[type="search"] {
padding: 8px 8px 8px 32px;
}
a i{
// display:flex;
float:right;
}
</style>
Since the navbar is fixed at the top then you can use
ul{
position: absolute;
display: flex;
right: 0;
flex-direction: row !important; // because navbar-nav direction set to column
gap: 1rem;
margin-right: 1rem;
}

section overlap in moblie mode css

I'm new to HTML and CSS and I'm trying to design a website from some source code that I found.
When I open the page on the web, It shows as follows:
When I open this page of a mobile device it appears as follows:
When on a mobile device, the section of Download the app overlaps the phone image that I added.
How can I make sure that the whole blue section will be below the image?
The parts of the .css that I found relevant are:
.home-image-right {
display: block;
position: absolute;
right: 0;
top: 55%;
-webkit-transform: translateY(-68%);
-ms-transform: translateY(-68%);
transform: translateY(-68%);
padding-top: 21rem;
z-index: 500;
width: 50%;
text-align: right;
}
.home-image-right img {
vertical-align: bottom;
width: 75%;
}
#download {
background: #2c80c4;
color: #ffffff;
padding-top: 12rem;
padding-bottom: 12rem;
text-align: center;
}
#download h1 {
color: #ffffff;
}
#download h1::before {
background-color: #ffffff;
left: 50%;
-webkit-transform: translateX(-50%);
-ms-transform: translateX(-50%);
transform: translateX(-50%);
}
#download .lead {
color: #ffffff;
margin-top: 4.8rem;
}
#download .row {
max-width: 800px;
}
#download .download-badges {
list-style: none;
margin: 0;
text-align: center;
}
#download .download-badges li {
display: inline-block;
margin: 0 7.5px;
padding-left: 0;
}
#download .download-badges li a {
display: block;
width: 230px;
height: 71px;
font: 0/0 a;
text-shadow: none;
color: transparent;
background-repeat: no-repeat;
background-position: center;
background-size: 230px 71px;
}
<div class="overlay"></div>
<div class="home-content">
<div class="row contents">
<div class="home-content-left">
<img src="images/logo.png" srcset="images/logo.png 1x" data-aos="fade-up">
<h1 data-aos="fade-up">
....
</h1>
<div class="buttons" data-aos="fade-up">
<a href="#download" class="smoothscroll button stroke">
<span class="icon-circle-down" aria-hidden="true"></span> Download App
</a>
</div>
</div>
<div class="home-image-right">
<img src="images/screen.png" srcset="images/screen.png 1x" data-aos="fade-up">
</div>
</div>
</div>
<!-- end home-content -->
<div class="home-scrolldown">
<a href="#about" class="scroll-icon smoothscroll">
<span>Scroll Down</span>
<i class="icon-arrow-right" aria-hidden="true"></i>
</a>
</div>
</section>
<!-- end home -->
<!-- download
================================================== -->
<section id="download">
<div class="row">
<div class="col-full">
<h1 class="intro-header" data-aos="fade-up">Download Our App Today!</h1>
<ul class="download-badges">
<li>Play Store</li>
</ul>
</div>
</div>
</section>
<!-- end download -->
Thank you
you may style your website with two specific css coding one is for desktop view and other one is for mobile view you want to use this media tag and write your css for mobile view into this
you may change the max-with value since 1px
it make if your device width is smaller than 600px it change the background-color to light blue
#media only screen and(max-width: 600px){
body{
background-color:light blue;
}
}
https://www.w3schools.com/css/css3_mediaqueries_ex.asp
Hmm that´s hard to say, without knowing where the image is. But i think this is your problem:
.home-image-right {
display: block;
position: absolute;
right: 0;
top: 55%;
-webkit-transform: translateY(-68%);
-ms-transform: translateY(-68%);
transform: translateY(-68%);
padding-top: 21rem;
z-index: 500;
width: 50%;
text-align: right;
}
position: absolute.
When assigning a position, you take out this section from the flow.
Take a look here: https://www.w3schools.com/css/css_positioning.asp

z-index on hover with bootstrap img-responsive class

Newb here. I am building a site, and on this site I am displaying overlapping images. Therefore, I am using the z-index on hover so that the behind image comes forward when hovered over. However, I am also using bootstrap and the img-responsive tag and when I hover, the image flickers and then disappears. How can I fix this? Is it possible to handle this in only HTML/CSS, no Java?
#container1 {
position: absolute;
top: 25%;
left: 35%;
}
#container1 img:hover {
z-index: 3;
position: absolute;
}
#container2 {
position: absolute;
top: 30%;
left: 25%;
}
#container2 img:hover {
z-index: 2;
position: absolute;
}
#container3 {
position: absolute;
top: 45%;
left: 40%;
}
#container3 img:hover {
z-index: 1;
position: absolute;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Lato:100,100italic,300,300italic,500,500italic,700,700italic, 800">
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#main-navbar" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Philesq</a>
</div>
<div class="collapse navbar-collapse" id="main-navbar">
<ul class="nav navbar-nav navbar-right">
<li>works
</li>
<li>about
</li>
<li>contact
</li>
</ul>
</div>
</div>
</nav>
<div id="container">
<div id="container1">
<img src="http://placehold.it/300x300?text=1" class="img-responsive">
</div>
<div id="container2">
<img src="http://placehold.it/300x300?text=2" class="img-responsive">
</div>
<div id="container3">
<img src="http://placehold.it/300x300?text=3" class="img-responsive">
</div>
<div>
I there.
The reason why the images flickers is because you are setting the images to be position absolute on hover and it has a static position by default.
If you set alle the images to be position relative from the beginning, and also removes the position attribute on hover, it will work. You do not need position absolute on the images because you have it on the parent container. (unless you are trying to do more I don't know of)
Hope this helps :)
Se working example here
#container1 img, #container2 img, #container3 img{
position: relative; /* Added this */
border: 1px solid red;
}
#container1 {
position: absolute;
top: 25%;
left: 35%;
}
#container1 img:hover {
z-index: 3;
/* Removed: position: absolute; */
}
#container2 {
position: absolute;
top: 30%;
left: 25%;
}
#container2 img:hover {
z-index: 2;
}
#container3 {
position: absolute;
top: 45%;
left: 40%;
}
#container3 img:hover {
z-index: 1;
}

Why does my div also include a div that is not its child?

Can you please check out this fiddle:
https://jsfiddle.net/3047p0wy/
Here is the HTML:
<nav class="navbar navbar-default">
<div class="container-fluid" id="navigation-bar">
<div class="navbar-header">
<div class="headerspace">
<a href="http://google.com">
<span>The title</span>
</a>
</div>
</div>
<div class="collapse navbar-collapse" id="navbar-collapse-element">
<ul class="nav navbar-nav navbar-right" id="tabs">
<li>
<div class="tab">
<a href="http://google.com">
<div class="greysquare">
<div class='greysquare-content'>
<div>
<span>EX</span></div>
</div>
</div>
<div class="notgreysquare"><span>PLORE</span></div>
</a>
</div>
</li>
</ul>
</div>
</div>
</nav>
And the css is as follows:
.navbar {
height: 100%;
margin-top: 10px;
background-color: inherit;
border: none;
}
.navbar-header {
height: 100%;
width: 30%;
}
#navigation-bar {
height: 100%;
}
#navbar-collapse-element {
height: 100%!important;
}
#tabs {
max-height: 100%;
}
.tabspace {
max-height: 100%;
width: 70%;
}
.tab {
margin-left: 5%;
margin-top: 1%;
max-height: 100%;
}
.greysquare,
.notgreysquare {
display: inline;
}
.greysquare {
display: block;
width: 70px;
background-color: #CCCCCB;
height: 100%;
max-height: 100%;
}
.greysquare:before {
content: "";
display: block;
padding-top: 100%;
}
.greysquare-content {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
.greysquare-content div {
display: table;
width: 100%;
height: 100%;
}
.greysquare-content span {
display: table-cell;
text-align: right;
vertical-align: bottom;
}
.notgreysquare {
height: 100%;
}
Basically I have this navbar, and inside it I am trying to work with each navigation tab. The idea is to have the first two letters of a link inside a grey square so that the letter were in the bottom right corner of the square and then the rest of the word was outside of the grey square but on the same line with the first two letters. See the image above to understand what I am looking for (can ignore the colours).
I started with following another fiddle that I found here: https://jsfiddle.net/josedvq/38Tnx/
So, as you can see, of the word EXPLORE, the EX is, indeed, placed in the right span, but the greysquare-content, for some reason, at least visually includes the PLORE part of the title which is not even its child, and I cannot figure out why it happens.
I would appreciate any help, really.
Is this what you're looking for:
https://jsfiddle.net/3047p0wy/3/
The HTML
<nav class="navbar navbar-default">
<div class="container-fluid" id="navigation-bar">
<div class="navbar-header">
<div class="headerspace">
<a href="http://google.com">
<span>The title</span>
</a>
</div>
</div>
<div class="collapse navbar-collapse" id="navbar-collapse-element">
<ul class="nav navbar-nav navbar-right" id="tabs">
<li>
<div class="tab">
<a href="http://google.com">
<div style="display: block;">
<span class="greysquare-content pull-left">EX</span>
<span class="notgreysquare pull-left">PLORE</span>
</div>
</a>
</div>
</li>
</ul>
</div>
</div>
</nav>
and the CSS
.navbar {
height: 100%;
margin-top: 10px;
background-color: inherit;
border: none;
}
.navbar-header {
height: 100%;
width: 30%;
}
#navigation-bar {
height: 100%;
}
#navbar-collapse-element {
height: 100%!important;
}
#tabs {
max-height: 100%;
}
.tabspace {
max-height: 100%;
width: 70%;
}
.greysquare-content {
background-color: #CCCCCB;
padding: 5px;
}
.notgreysquare {
padding: 5px 5px 5px 0px;
}

Need help centering social media icons in the a footer on a website

I have been stuck on something very simple for over a day now and I have to ask for help. I am trying to do something simple as centering vertically my social media icons in my footer. I tried to take the same route when someone helped me with the Navigation Bar but I just cannot seem to grasp/understand something to get the same result.
I thought about doing padding but I was not sure if that still would take care of re-sizing or smaller screens, so I wanted to take more a percent route instead of flat amount.
Website for Inspect
Footer HTML:
<!-- Social Media + Footer -->
<div class="container">
<div class="navbar navbar-fixed-bottom">
<div class="collapse navbar-collapse">
<div class="row">
<div class="col-md-12">
<ul class="nav navbar-nav">
<li>
<img src="link/ico-facebook.png"
alt="Facebook Icon"
style="width: 100%; height: auto; max-width: 32px">
</li>
<li>
<img src="link/ico-twitter.png"
alt="Twitter Icon"
style="width: 100%; height: auto; max-width: 32px">
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<!-- End of Social Media + Footer -->
CSS:
.container {
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
}
.navbar-fixed-bottom {
bottom: 0;
margin-bottom: 0;
border-width: 0 0 0;
position: relative;
right: 0;
left: 0;
z-index: 1030;
-webkit-transform: translate3d(0,0,0);
-o-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
}
.navbar {
position: relative;
min-height: 100px;
margin-bottom: 20px;
border: 1px solid transparent;
}
.navbar-collapse.collapse {
display: block!important;
height: auto!important;
padding-bottom: 0;
overflow: visible!important;
}
#media (min-width: 768px) .navbar-collapse {
width: auto;
border-top: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
.navbar-collapse {
text-align: center;
padding-right: 15px;
padding-left: 15px;
overflow-x: visible;
-webkit-overflow-scrolling: touch;
border-top: 1px solid transparent;
-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.1);
box-shadow: inset 0 1px 0 rgba(255,255,255,.1);
}
.collapse {
display: none;
}
#media (min-width: 768px).navbar-nav {
display: inline-block;
float: none;
vertical-align: middle;
margin: 0;
}
.navbar-nav {
margin: 7.5px -15px;
text-align: center;
}
.nav {
padding-left: 0;
margin-bottom: 0;
list-style: none;
}
#media (min-width: 768px).navbar-nav>li {
display: inline-block!important;
}
.nav>li {
position: relative;
display: inline-block!important;
}
img.element.style {
width: 100%;
height: auto;
max-width: 32px;
}
img {
vertical-align: middle;
}
You could do it by apply some custom CSS to your HTML elements:
<div class="navbar navbar-fixed-bottom" style="display: table !important; width: 100%;">
<div class="collapse navbar-collapse" style="vertical-align: middle;display: table-cell !important;">
......
......
</div>
</div>
I was the one who answered you the first time, so here I go again to make sure you understand how it works.
First, let's do a tiny change in your HTML markup, as follows:
<!-- Social Media + Footer -->
<div class="container">
<div class="navbar navbar-fixed-bottom">
<div class="collapse navbar-collapse vertimid">
<div class="row">
<div class="col-md-12">
<ul class="nav navbar-nav">
<li>
<img src="link/ico-facebook.png"
alt="Facebook Icon"
style="width: 100%; height: auto; max-width: 32px">
</li>
<li>
<img src="link/ico-twitter.png"
alt="Twitter Icon"
style="width: 100%; height: auto; max-width: 32px">
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<!-- End of Social Media + Footer -->
If you pay attention, I have only added the class .vertimid to the line
<div class="collapse navbar-collapse">
we do this in order to accurately target that class so you can re-use it later, as I told you the other day.
Now, you do add this property to
.navbar-collapse.vertimid{display:inline-block} /* replaces display:table */
and that's it.
Remember: you need to vertical align elements relative to the container block. Also, as we're at it, be sure to check your site in Firefox, because you'll find out your social media icons aren't there
Decide what height percentage of the footer you want your social media icons to be...suppose 30%:
ul.nav {
height:30%;
margin-top:35%;
margin-bottom:35%;
}