Is it possible to create the Firefox tab using CSS ? [duplicate] - css

This question already has answers here:
Add outward curving border to elements like this: ◝◟___◞◜
(3 answers)
Closed 7 years ago.
I can't find a non-ugly (no extra markup or fixed width) way to do draw the Firefox tab shape with CSS.
Even Mozilla use a png image.

if you use a basic <nav> or a list (<ul>) , you could achieve this from a single link(<a>) and pseudo-elements DEMO
nav,
ul {
padding: 0 0 0.25em;
}
li {
display: inline-block;
padding: 0 1.2em;
}
li a {
display: inline-block;
line-height: 2em;
color: white;
padding: 0 0.5em;
border-radius: 0 0 2em 2em/2.5em;
position: relative;
}
li a:before,
li a:after {
content: '';
position: absolute;
height: 2em;
width: 1.25em;
top: 0;
}
li a:before {
right: 100%;
border-radius: 0 1em 0 0/1.5em
}
li a:after {
left: 100%;
border-radius: 1em 0 0 0/1.5em
}
nav {
background: #0976B8;
}
li a:hover,
li a.active {
background: white;
color: #0976B8
}
li a:hover:before,
li a.active:before {
box-shadow: 0.5em -1em 0 white;
}
li a:hover:after,
li a.active:after {
box-shadow: -0.5em -1em 0 white;
}
<nav>
<ul>
<li>Home</li>
<li>About</li>
<li>Clients</li>
<li>Contact Us</li>
</ul>
</nav>
tune the border-radius to the shape you look for

Codepen Demo
Okay, I have come up with an extremely messy solution, but, it only requires a single HTML element:
#charset "UTF-8";
body, html {
margin: 0;
width: 100%;
height: 100%;
background: #079FD9;
}
div {
background: white;
/*Note that if you change this color, make sure you change the background of the pseudo elements*/
display: inline-block;
padding: 10px;
padding-right: 20px;
/*These paddings are to make sure the pseudo elements do not overlap the text*/
padding-left: 20px;
border-radius: 0 0 10px 10px;
position: relative;
margin-left: 30px;
color: #079FD9;
font-family: open sans;
/*This is, of course, optional*/
font-size: 16pt;
}
div:before, div:after {
content: "•";
/*Very Hacky*/
font-family: Times New Roman !important;
/*Makes sure the font won't mess it up*/
color: #079FD9;
/*Change this to the background color *around* the element*/
font-size: 200px;
line-height: 7px;
position: absolute;
overflow: hidden;
top: 0px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
width: 30px;
height: 30px;
background: white;
}
div:after {
right: -19px;
-webkit-transform: rotateX(180deg);
transform: rotateX(180deg);
}
div:before {
left: -19px;
-webkit-transform: rotateY(180deg) rotateX(180deg);
transform: rotateY(180deg) rotateX(180deg);
}
<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<div>Mozilla</div>
It is a very hacky solution, and uses a bullet(•) to cover the div. But it works.
You will have to play around with it until you find how you want it to work.

Related

Drop down menu is not opening while mouse over

i am just a beginning in HTML5 and CSS. Im trying to make a dropdown menu but something is going wrong. Looking a while into it but cannot find my mistake. I hope somebody is willing to help me! Here below my CSS coding.. If theres some questions or details needed comments i would love to hear them ofcourse.
*{
margin: 0;
padding: 0;
front-family: century gothic;
}
header{
background-image:linear-gradient(rgba(0,0,0,0.5),rgba(0,0,0,0.5)), url(image.jpg);
height: 100vh;
background-size: cover;
background-position: center;
}
ul{
float: right;
list-style-type: none;
margin-top: 25px;
}
ul li{
display: inline-block;
}
ul li a{
text-decoration:none;
color:#fff;
padding:5px 20px;
border:2px solid transparent;
transition: 0.8s ease;
}
ul li a:hover{
background-color:#fff;
color: #000;
}
ul li.active a{
background-color:#fff;
color: #000;
}
/* Dropdown Button */
.dropbtn {
background-color: #fff;
color: black;
padding: 16px;
font-size: 16px;
border: black;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
padding:10px 50px;
display: inline-block;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.logo img{
float:left;
width: 150px;
height: auto;
}
.main{
max-width: 1200px;
margin: auto;
}
.title{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%)
}
.title h1{
color: #fff;
font-size: 70px;
}
.button{
position: absolute;
top: 62%;
left: 50%;
transform: translate(-50%, -50%);
}
.btn{
border: 1px solid #fff;
padding: 10px 30px;
color: #fff;
text-decoration: none;
transition: 0.6s ease;
}
.btn:hover{
background-color: #fff;
color: #000;
}
There is nothing in your CSS, telling the .dropdown-content to appear, when you hover. You could try something like this. I have copied your CSS and added to it, also adding in some HTML:
*{
margin: 0;
padding: 0;
font-family: century gothic;
}
header{
background-image:linear-gradient(rgba(0,0,0,0.5),rgba(0,0,0,0.5)), url(image.jpg);
height: 100vh;
background-size: cover;
background-position: center;
}
ul {
float: right;
list-style-type: none;
margin-top: 25px;
}
ul li{
display: inline-block;
}
ul li a{
text-decoration:none;
color:#fff;
padding:5px 20px;
border:2px solid transparent;
transition: 0.8s ease;
}
ul li a:hover{
background-color:#fff;
color: #000;
}
ul li.active a{
background-color:#fff;
color: #000;
}
/* Dropdown Button */
.dropbtn {
background-color: #fff;
color: black;
padding: 16px;
font-size: 16px;
border: black;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
padding:10px 50px;
display: inline-block;
}
.dropbtn:hover ~ .dropdown .dropdown-content {
display: block;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.logo img{
float:left;
width: 150px;
height: auto;
}
.main{
max-width: 1200px;
margin: auto;
}
.title{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%)
}
.title h1{
color: #fff;
font-size: 70px;
}
.button{
position: absolute;
top: 62%;
left: 50%;
transform: translate(-50%, -50%);
}
.btn{
border: 1px solid #fff;
padding: 10px 30px;
color: #fff;
text-decoration: none;
transition: 0.6s ease;
}
.btn:hover{
background-color: #fff;
color: #000;
}
<header>
<div class="dropbtn">show dropdown</div>
<div class="dropdown">
<div class="dropdown-content">
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
</div>
</div>
</header>
I am using the general sibling selector ~, to make my :hover CSS work. I can improve this answer after seeing your actual HTML.

why is width: 100% working on this list item?

I'm creating a mobile nav and I have drop down menu on the charactors tab, with a back button on top made of simply a list item with text. With the back button though width 100% doesn't seem to be working I have check the dev tools and its seems like its should be working, I need it to be acting like the rest of the list items and its seem be be acting like its an inline element why?
the back a button only appears on widths 400px or less
https://jsfiddle.net/6e62ge46/11/
header nav{
position: fixed;
bottom: 0;
width: 100%;
z-index: 1;
// background-color: rgba(255,165,0,.8);
}
nav ul {
list-style: none;
padding: 0;
}
.main-nav{
margin: 0;
width: 100%;
color: white;
font-family: arial;
font-weight: 600;
}
nav ul li{
text-align: center;
border: 1px solid white;
border-radius: 15px;
font-size: 1.2rem;
background-color:rgba(255,165,0,.8);
width: 100%;
}
.drop-menu-back{
display: none;
width: 100%;
}
a{
text-decoration: none;
}
nav a:visited, nav a,h1{
color: white;
}
.main-nav .current-page {
background-color: rgba(0,0,0,.5);
}
/****drop down menu****/
.characters:hover {
position: relative;
border-radius: 8px 8px 0 0;
}
.drop-menu{
position: absolute;
visibility: hidden;
display: block;
top: 38px;
white-space: nowrap;
left: -2px;
background-color: rgba(255,165,0,.8);
border: 1px solid rgba(0,0,0,.02);
box-shadow: 5px 5px 5px 2px rgba(0,0,0,.3);
opacity: 0;
transition: opacity 300ms ease-in-out 0s;
z-index: 1;
}
.characters:hover .drop-menu{
visibility: visible;
opacity:1;
}
#media screen and (max-width: 400px) {
.drop-menu{
top:-50px;
width: 100%;
}
.drop-menu-back{
display: initial;
width: 100%;
}
}

Autowidth on fixed element don't work on IE11

I am facing an issue on IE11 on a fixed element. That's a context menu that needs to grow horizontally depending on the text inside. This works perfectly on Firefox, Chrome and Safari, but not on IE.
The problem is that on IE11 the right arrow goes down to the next line, instead of growing the line to allow all text be shown.
The following is my code:
* {
box-sizing: border-box;
}
#context-menu {
display: none;
text-align: left;
position: fixed;
z-index: 1000000000;
}
#context-menu ul {
background-color: white;
border: 1px solid #ccc;
border-radius: 5px;
box-shadow: 1px 1px 3px #444;
text-align: left;
min-width: 150px;
width: auto;
}
#context-menu ul,
#context-menu ul li {
padding: 0;
margin: 0;
position: relative;
display: block;
width: auto;
color: black;
text-align: left;
background-color: #fff;
}
#context-menu ul li {
padding: 5px 10px;
cursor: pointer;
}
#context-menu ul li:hover ul {
z-index: 1;
}
#context-menu ul li:first-child {
border-radius: 3px 3px 0 0;
}
#context-menu ul li:last-child {
border-radius: 0 0 3px 3px;
}
#context-menu ul li .fa {
margin-right: 10px;
width: 15px;
vertical-align: middle;
}
#context-menu ul li.group {
cursor: default;
background-color: #dfdfdf;
font-weight: bold;
}
#context-menu ul > li:not(.group):hover {
background-color: hsla(208, 56%, 53%, 1);
color: black;
}
#context-menu ul > li.submenu::after {
font-family: FontAwesome;
content: "\f105";
margin-left: 15px;
float: right;
}
#context-menu ul> li > ul{
display: none;
}
#context-menu ul > li:hover > ul {
display: block;
position: absolute;
left: 100%;
top: 0;
}
<link href="https://opensource.keycdn.com/fontawesome/4.7.0/font-awesome.min.css" rel="stylesheet"/>
<div id="context-menu" style="display: block;">
<ul>
<li><span class="optionText">Long text to show the problem here on the right arrow</span></li>
<li class="submenu"><span class="optionText">Another text</span></li>
<li class="submenu"><span class="optionText">Long text to show the problem here on the right arrow</span>
<ul class="dropdownright">
<li><span class="optionText">Other</span></li>
</ul>
</li>
</ul>
</div>
If you see, if the text is longer than the min-width, it grows on all browsers except IE11, where the arrow goes down to the next line.
How can I make it grow the width automatically ?
Thank you.
Removing the "float: right" in the rule "#context-menu ul > li.submenu::after" seems to be working for me in Internet explorer 11.

Nav Menu items Underline effect

I'm trying to have navigation menu items have underline effect when hovering. This is my current style.css code for the navigation menu.
What should I add to make it look something like this? Example: http://www.templatemonster.com/demo/54038.html .
This is my current nav bar code.
.navbar-nav .open .dropdown-menu{
display:block !important;
}
.navbar-default .navbar-nav > li > a {
color: #333;
border-bottom: 1px solid transparent;
padding: 0;
margin: 14px;
Try this..
HTML:
<ul>
<li>About</li>
</ul>
CSS:
body,html {
margin: 0;
}
ul {
margin: 150px auto 0;
padding: 0;
list-style: none;
display: table;
width: 600px;
text-align: center;
}
li {
display: table-cell;
position: relative;
padding: 15px 0;
}
a {
color: #000;
text-transform: uppercase;
text-decoration: none;
letter-spacing: 0.15em;
display: inline-block;
padding: 15px 20px;
position: relative;
}
a:after {
background: none repeat scroll 0 0 transparent;
bottom: 0;
content: "";
display: block;
height: 2px;
left: 50%;
position: absolute;
background: #000;
transition: width 0.3s ease 0s, left 0.3s ease 0s;
width: 0;
}
a:hover:after {
width: 100%;
left: 0;
}
https://jsfiddle.net/y4hc9Lbv/

Height 100% not working

So I have a div that is supposed to have 100% height. It's only parent element is <body>, so 100% should be the height of the window. But instead of spanning the height of the screen, it only is as high as the container element inside it. The funny thing is, if I use fixed positioning, it does what I want it to. Alas, I can't use fixed in the site layout. Here is my css. If you would like to see what the site looks like right now, here is the link: http://ion.comli.com/projects/
body, ul {
margin: 0;
padding: 0;
}
body {
background: url('/images/background.png') no-repeat fixed;
}
/* CONTENT */
.content{
margin-left: auto;
margin-right: auto;
    position: absolute;
    top: 50px;
    left: 15%;
height: 100%;
width: 70%;
background-color: #ffffff;
}
/* END CONTAINER*/
/* CONTAINER */
.container{
background: #ffffff;
margin: 5% 10%;
text-align: center;
}
.container .title a {
font-family: Franchise, "sans-serif";
font-size: 48px;
color: black;
line-height: 48px;
text-align: center;
text-decoration: none;
}
.container .date {
font-family: Ubuntu, "sans-serif";
font-size: 12px;
color: #666666;
line-height: 12px;
text-align: center;
text-decoration: none;
}
.container .body {
font-family: Ubuntu, "sans-serif";
font-size: 16px;
text-align: left;
}
/* END CONTAINER */
/* PROJECT */
.project {
display: block;
margin: 5% auto;
height: 100px;
width: 500px;
border-radius: 10px;
background: url("/images/background.png");
opacity: 0.5;
}
.project h2 {
font-family: Franchise;
font-size: 48px;
color: white;
text-align: center;
}
/* END PROJECT */
/* NAVIGATION */
nav ul {
background-color: #1b1b1b;
display: table;
list-style: none;
position: fixed;
top: 0;
height: 50px;
width: 100%;
box-shadow: 0 0 6px #888888;
z-index: 1;
}
nav ul li {
float: left;
}
nav ul li a {
display: table-cell;
height: 50px;
line-height: 50px;
padding: 0 65px;
font-family: Ubuntu;
font-size: 16px;
color: #ffffff;
text-decoration: none;
background-color: #292929;
}
nav #title {
font-family: Lobster;
font-size: 36px;
line-height: 50px;
border-right: 1px solid #ffffff;
background-color: #1b1b1b;
}
nav #menu {
padding: 0 25px;
background-color: #1b1b1b;
}
nav #menu:hover {
box-shadow: none;
background-color: #292929;
}
nav li:hover #menu {
box-shadow: none;
background-color: #292929;
}
nav ul ul {
background: #292929;
display: none;
position: absolute;
top: 100%;
right: 0px;
width: 15%;
}
nav ul ul li {
background: #292929;
float: left;
position: relative;
clear: both;
}
nav ul li:hover > ul {
box-shadow: none;
display: block;
}
/* END NAVIGATION */
/* SCROLLBAR */
/* END SCROLLBAR */
Any way I can get this div to span the whole 100%? I'm pretty sure there is a simple answer to this question, but I can't find it. Thanks in advance!
You have to make sure all parents of .content have a height defined.
So in your case what is missing is:
html, body {
height: 100%;
}
Alternative
Or you could position .content as fixed and you'd have the same effect but with a different approach
.content {
position: fixed;
top: 0;
left: 0;
height: 100%;
}
Make body 100% high
html, body {
height: 100%;
}

Resources