I have the following snippet to render an icon overlapped with another. The whole div is a link. Currently I'm using position:absolute and adjusting the overlap. How can I do it without the absolute position. I also want the whole div on the right side of the screen (currently its on the left).
.btn-circle {
position: absolute;
top: 4px;
left: 25px;
width: 30px;
height: 30px;
line-height: 30px;
background: red;
border-radius: 50%;l
}
.count {
position: absolute;
top:8px;
left:38px;
font-size:16px;
font-weight: bold;
color:white;
}
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<div class="">
<a href="#">
<i class="fa fa-inbox fa-2x"></i>
<span id="red-circle" class="btn btn-circle"></span>
<span id="toDosCount" class="count">9</span>
</a>
</div>
You can still use absolute positioning alongside float: right if you make the containing div have position: relative
This makes the absolute positions of the inner spans relative to the div rather than the page.
A few tweaks to the top and right/left values and:
.btn-circle {
position: absolute;
top: -4px;
right: -4px;
width: 20px;
height: 20px;
background: red;
border-radius: 50%;
}
.count {
position: absolute;
top: -4px;
right: -1px;
font-size:16px;
font-weight: bold;
color:white;
padding: 2px;
}
.wrapper {
float: right;
position: relative;
margin-right: 100px;
}
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<div class="wrapper">
<a href="#">
<i class="fa fa-inbox fa-2x"></i>
<span id="red-circle" class="btn btn-circle"></span>
<span id="toDosCount" class="count">9</span>
</a>
</div>
I also nudged the whole thing to the left a little so it wasn't obscured by the snippet FULL PAGE
Either you need to position it correctly or reduce the font size:
Snippet
.btn-circle {
position: absolute;
top: -15px;
right: 0;
width: 15px;
height: 15px;
line-height: 15px;
background: red;
border-radius: 50%;
}
div a {position: relative;}
.count {
position: absolute;
top: -15px;
right: 5px;
font-size: 10px;
font-weight: bold;
color: white;
text-align: center;
}
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<div class="">
<a href="#">
<i class="fa fa-inbox fa-2x"></i>
<span id="red-circle" class="btn btn-circle"></span>
<span id="toDosCount" class="count">9</span>
</a>
</div>
Does this work for you?
Related
I have to create a list menu that is only icons and when you hover over it, the hidden text eases out right to left. Unfortunately I don't know transitions well enough to accomplish this. What I currently have transitions out, but the whole menu comes with it. Here's a snippet of what I mean
https://codepen.io/onesneakymofo/pen/qBdxyjB
HTML:
<div class="box">
<ul>
<li>
<span class="hide-me">Users</span>
<span class="fas fa-list fa-user fa-2x fa-inverse icon"></span>
</li>
<li>
<span class="hide-me">Email</span>
<span class="fas fa-list fa-envelope fa-2x fa-inverse icon"></span>
</li>
<li>
<span class="hide-me">Settings</span>
<span class="fas fa-list fa-cog fa-2x fa-inverse icon"></span>
</li>
</ul>
</div>
CSS:
.box{
position: relative;
background: tomato;
height: 500px;
width: 500px;
}
ul {
z-index: 1;
position: absolute;
right: 10px;
}
li {
position: relative;
list-style: none;
height: 50px;
width: 50px;
padding: 5px;
right: 25px;
line-height: 0;
margin-bottom: 25px;
top: 5px;
background: #333;
border-radius: 25px;
}
.hide-me{
font-size: 26px;
opacity: 0;
}
li:hover{
top: 0px;
background-color: orange;
transition: width 1s ease-out;
width: 125px;
}
li:hover .hide-me {
opacity: 100;
transition: opacity .35s;
position: absolute;
top: 25px;
}
li:hover .icon {
position: absolute;
right: 5px;
top: 5px;
}
span {
color: #fff;
}
The closest thing that I have found to what I want is
https://stackoverflow.com/a/52211712
but when I try to make it into a list, the same thing from my snippet happens.
Thanks.
You can use ::after and position:absolute to put content behind your menu, and :hover::after to then move it out from behind. The relevant CSS is in the head of the HTML below.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<style>
li {
background-color: white;
display: inline-block;
}
li::after {
content: "12345";
position: absolute;
left: 50px;
transition: all 1s ease;
z-index: -1;
}
li:hover::after {
left: 200px;
transition: all 1s ease;
}
</style>
</head>
<body>
<ol>
<li>qwertyuiop asdf</li>
<br>
<li>qwertyuiop asdf</li>
<br>
<li>qwertyuiop asdf</li>
<br>
</ol>
</body>
</html>
I'm trying to create drop-down menus under the various categories but whenever I hover over them, the dropdown menu appears to the left of the button. Any suggestions on how to fix? Link to my code below
Here is jsFiddle link:
body {
margin: 0px;
overflow-x: hidden;
}
.content {
font-family: verdana;
font-size: 30px;
}
.donate {
background-color: orange;
border: white;
color: rgb(255, 255, 255);
padding: 7px 14px;
font-size: 15px;
border-radius: 8px;
}
.donate:hover {
background-color: rgb(102, 51, 0);
color: rgb(255, 255, 255);
}
.divnav {
width: 100%;
overflow: hidden;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropbtn {
font-size: 13px;
border: none;
outline: none;
background-color: inherit;
float: right;
display: block;
margin: 3px 3px 3px 3px;
font-family: verdana;
font-weight: 550;
}
.dropbtn:hover {
color: orange;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
overflow: auto;
}
.dropdown:hover .dropdown-content {
display: block;
}
html {}
.image {
overflow: hidden;
}
.navbar {
width: 80%;
margin-left: auto;
margin-right: auto;
text-align: center;
}
.navelement {
float: right;
display: block;
margin: 3px 3px 3px 3px;
font-family: verdana;
font-size: 13px;
font-weight: 550;
}
.nava {
padding: 5px;
}
.nava:hover {
background-color: white;
color: orange;
}
.pagetitle {
height: 68px;
width: 100%;
background-image: url("pictures/titlebar1.jpg");
}
.par {
/* DIV THAT GOES UNDER TODOCONTENT ONLY AND MARKS A PARAGRAPH WITH INFORMATIVE CONTENT*/
}
.parcontent {
font-family: verdana;
color: rgb(150, 150, 150);
font-size: 15px;
}
.titleimage {
overflow: hidden;
height: 310px;
margin: 0px;
width: 100%;
}
.title {
font-family: verdana;
font-size: 50px;
color: white;
}
.todocontent {
width: 47%;
/* A DIV WITH CLASS TODOCONTENT MEANS A DIV THAT WILL CONTAIN ALL INFORMATIVE CONTENT OF THE PAGE*/
}
.wrapper {
width: 100%;
height: 5%;
overflow: hidden;
}
<div class="titleimage">
<img src="C:\Users\kiran.nair\Desktop\Internship\current\pictures\heading2.jpg" alt="GLI.logo" style="width:100%;height:100%;">
</div>
<div class="divnav">
<div class="wrapper" style="POSITION: absolute; TOP: 300px; LEFT: 0px;">
<img src="C:\Users\kiran.nair\Desktop\Internship\current\pictures\wrapper.png" alt="wrapper" style="width:20000px;height:5px;">
</div>
<div style="POSITION: relative; TOP: 20px; LEFT: 15%;">
<img src="C:\Users\kiran.nair\Desktop\Internship\current\pictures\GLI.logo.png" alt="GLI.logo" style="width:145px;height:152px;">
</div>
<div style="POSITION: relative; TOP: -20px; LEFT: 10%;">
<ul class="navbar">
<div class="dropdown">
<button class="dropbtn">CONTACT</button>
<div class="dropdown-content" style="POSITION: relative; TOP: 20px;">
contact
</div>
</div>
<div class="dropdown">
<button class="dropbtn">RESEARCH</button>
<div class="dropdown-content" style="POSITION: relative; TOP: 10px;">
research
</div>
</div>
<div class="dropdown">
<button class="dropbtn">TRIP PREP</button>
<div class="dropdown-content" style="POSITION: relative; TOP: 10px;">
TRIP PREP
</div>
</div>
<div class="dropdown">
<button class="dropbtn">UPCOMING EVENTS</button>
<div class="dropdown-content" style="POSITION: relative; TOP: 10px;">
UPCOMING EVENTS
</div>
</div>
<div class="dropdown">
<button class="dropbtn">MEDIA</button>
<div class="dropdown-content" style="POSITION: relative; TOP: 10px;">
MEDIA
</div>
</div>
<div class="dropdown">
<button class="dropbtn">ENTUSI EVENTS</button>
<div class="dropdown-content" style="POSITION: relative; TOP: 10px;">
ENTUSI EVENTS
</div>
</div>
<div class="dropdown">
<button class="dropbtn">PROGRAMS</button>
<div class="dropdown-content" style="POSITION: relative; TOP: 10px;">
PROGRAMS
</div>
</div>
<div class="dropdown">
<button class="dropbtn">ABOUT</button>
<div class="dropdown-content" style="POSITION: relative; TOP: 10px;">
ABOUT
</div>
</div>
<div class="dropdown">
<button class="dropbtn">HOME</button>
<div class="dropdown-content" style="POSITION: relative; TOP: 10px;">
HOME
</div>
</div>
</ul>
</div>
<div class="divdonate" style="POSITION: relative; TOP: -140px; LEFT: 80%;">
<button class="donate">DONATE NOW</button>
</div>
</div>
<body>
<div>
<div class="pagetitle">
<div>
<header class="title" style="POSITION: relative; LEFT: 15%">Uganda</header>
</div>
</div>
<div class="todocontent" style="POSItiON: relative; TOP: 15%; LEFT: 15%;">
<div class="par" style="POSITION: relative; TOP: 15%; LEFT: 0%;">
<p class="parcontent">
Uganda was formed from the colonization of the Buganda Kingdom by the British in the 19th century. Britain wanted to protect the viability of the Nile River for its trading potential which prompted the British government to annex Buganda to create the
Uganda Protectorate in 1894. In 1962 Uganda regained its independence and declared itself a republic with Milton Obote as the first prime minister and former Bugandan King Muteesa as the president. Despite being largely ceremonial, Obote removed
the presidential position and established a new constitution in which he became a powerful president similar to a dictator. After committing many atrocities Obote was removed from power in a coup orchestrated by General Idi Amin who seized control
of the country. Amin proceeded to be nearly as atrocious as Obote when almost 500,000 citizens perished under his regime. Despite entering presidency with cheers, his actions made the country of Uganda hate him. After Amin was removed from power
by largely Tanzanian forces, Obote returned to presidency. A war broke out as a result from the election resulting in the deaths of between 100 and 500,000 people. This compelled 2 military commanders to conduct a coup in which Museveni gained
control. Yoweri Museveni remains in power till this date."
</p>
</div>
</div>
</div>
Images don't work but shouldn't matter right?
You should remove inline styles that you inserted for all elements with class .dropdown-content.
<div class="dropdown">
<button class="dropbtn">CONTACT</button>
<div class="dropdown-content" style="POSITION: relative; TOP: 20px;">
contact
</div>
</div>
This is called inline style. Style written directly on html element:
style="POSITION: relative; TOP: 20px;"
Next, you need to modify rule for .dropdown-content:
.dropdown-content{
/* Your code here */
top: 100%;
}
In image their are border that overlapped with my social icon i can't fix that
See in the pic
Border are come in background of social icons
This is my HTML
<div class="social text-center">
<p class="icons">
<i class="fa fa-facebook" aria-hidden="true"></i>
<i class="fa fa-google-plus" aria-hidden="true"></i>
<i class="fa fa-youtube" aria-hidden="true"></i>
<i class="fa fa-twitter" aria-hidden="true"></i>
<i class="fa fa-instagram" aria-hidden="true"></i>
</p>
<div class="divider">
</div>
This is css
.social {
position: relative;
}
.divider {
position: absolute;
border-top: 2px solid #fff;
width: 100%;
top: 50%;
}
Please solve this problem.
Thanks in advance :)
it's very simple if you use pseudo elements
check the snippet
.social {
overflow: hidden;
background: #333;
padding: 10px 5px;
text-align: center;
}
.icons {
position: relative;
display: inline-block;
vertical-align: top;
padding: 0 10px; /* you can use this padding for the space between icons and border */
}
.icons:before {
content: '';
position: absolute;
top: 50%;
right: 100%;
width: 9999px;
height: 1px;
background: #fff;
}
.icons:after {
content: '';
position: absolute;
top: 50%;
left: 100%;
width: 9999px;
height: 1px;
background: #fff;
}
<div class="social text-center">
<div class="icons">
<i class="fa fa-facebook" aria-hidden="true">123</i>
<i class="fa fa-google-plus" aria-hidden="true">123</i>
<i class="fa fa-youtube" aria-hidden="true">123</i>
<i class="fa fa-twitter" aria-hidden="true">123</i>
<i class="fa fa-instagram" aria-hidden="true">123</i>
</div>
</div>
<!-- remove "123" from icon -->
I am not sure where you want to put divider but following css will put at bottom.
.social {
position: relative;
}
.divider {
position: relative;
border-top: 2px solid #fff;
width: 100%;
}
.social {
width: 100%;
text-align: center;
}
.social h6 {
text-align: center;
font-size: 16px;
color: #a5a5a5;
font-weight: 300;
margin: 15px 0px;
display: inline-block;
position: relative;
}
.social h6:after,
.social h6:before {
content: '';
position: absolute;
width: 130px;
height: 1px;
display: block;
background-color: #a5a5a5;
}
.social h6:after {
right: 95px;
top: 12px;
}
.social h6:before {
left: 95px;
top: 12px;
}
<div class="social">
<h6>Follow Us</h6>
</div>
Here is flexslider element
'
<img alt="Zdjęcie" src="Image" />
<div>
<span class="promoted-d-caption">Year</span>
<span class="promoted-d-price" align="center">Price</span>
<span class="promoted-d-title">Title</span>
<span class="promoted-d-day-offer">Offer</span>
</div>
And css:
.promoted-d-title {
position: absolute;
bottom: 40px;
padding: 10px;
width: 100%;
font-size: 1.7em;
}
.promoted-d-caption {
position: absolute;
bottom: 0px;
padding: 10px;
width: 100%;
}
.promoted-d-price {
position: absolute;
bottom: 0px;
margin-left: 400px;
width: 150px;
padding: 5px;
padding-top: 3px;
font-size: 1.5em;
}
.promoted-d-day-offer {
position: absolute;
bottom: 90px;
margin-left: 430px;
width: 120px;
padding: 5px;
font-size: 1.5em;
z-index: 1001;
}
It is displayed properly, but while "sliding" animation, part of spans disappears and they appear when animation is completed (when next image is on it's proper position).
What could be reason? Why only part of elements disappears?
var slider = $('#test').flexslider({
animation: "slide"
});
.promoted-d-title {
position: absolute;
bottom: 40px;
padding: 10px;
width: 100%;
font-size: 1.7em;
background: #fffff0;
}
.promoted-d-caption {
position: absolute;
bottom: 0px;
padding: 10px;
width: 100%;
background: #fffff0;
}
.promoted-d-price {
position: absolute;
bottom: 0px;
margin-left: 400px;
width: 150px;
padding: 5px;
padding-top: 3px;
font-size: 1.5em;
background: #fffff0;
}
.promoted-d-day-offer {
position: absolute;
bottom: 90px;
margin-left: 430px;
width: 120px;
padding: 5px;
font-size: 1.5em;
z-index: 1001;
background: #fffff0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/flexslider/2.6.3/flexslider.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/flexslider/2.6.3/jquery.flexslider.min.js"></script>
<div class="col-md-12 main-promoted-area">
<table style="width: 100%">
<tr>
<td></td>
<td rowspan="2" style="width: 550px">
<div id="test" class="flexslider d-promoted">
<ul class="slides">
<li>
<div class="">
<img alt="Zdjęcie" src="http://vignette3.wikia.nocookie.net/thecornerclub/images/e/e1/Blast_500x500-1-.jpg/revision/latest?cb=20150213022400" />
<div>
<span class="promoted-d-caption">Year</span>
<span class="promoted-d-price" align="center">Price</span>
<span class="promoted-d-title">Title</span>
<span class="promoted-d-day-offer">Offer</span>
</div>
</div>
</li>
<li>
<div class="">
<img alt="Zdjęcie" src="http://vignette3.wikia.nocookie.net/thecornerclub/images/e/e1/Blast_500x500-1-.jpg/revision/latest?cb=20150213022400" />
<div>
<span class="promoted-d-caption">Year</span>
<span class="promoted-d-price" align="center">Price</span>
<span class="promoted-d-title">Title</span>
<span class="promoted-d-day-offer">Offer</span>
</div>
</div>
</li>
</ul>
</div>
</td>
<td></td>
</tr>
</table>
</div>
Add following CSS rule and your problem will be fixed.
.slides li div {
position: relative;
}
And instead of placing individual elements with position: absolute, Its better to place only one parent with absolute positioning and all child elements with normal styling as shown below:
<div class="caption-area">
<span class="promoted-d-title">Title</span>
<span class="promoted-d-caption">Year</span>
<span class="promoted-d-price">Price</span>
<span class="promoted-d-day-offer">Offer</span>
</div>
Having following styles:
.slides li div.caption-area {
position: absolute;
z-index: 10;
bottom: 0;
right: 0;
left: 0;
}
var slider = $('#test').flexslider({
animation: "slide"
});
.slides li div {
position: relative;
}
.slides li div.caption-area {
position: absolute;
z-index: 10;
bottom: 0;
right: 0;
left: 0;
}
.promoted-d-title {
display: block;
margin-bottom: 2px;
padding: 10px;
font-size: 1.7em;
background: #fffff0;
}
.promoted-d-caption {
display: block;
padding: 10px;
background: #fffff0;
}
.promoted-d-price {
position: absolute;
bottom: 0px;
right: 0;
width: 150px;
padding: 5px;
padding-top: 3px;
font-size: 1.5em;
background: #fffff0;
}
.promoted-d-day-offer {
margin-left: auto;
display: block;
width: 120px;
padding: 5px;
font-size: 1.5em;
background: #fffff0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/flexslider/2.6.3/flexslider.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/flexslider/2.6.3/jquery.flexslider.min.js"></script>
<div class="col-md-12 main-promoted-area">
<div id="test" class="flexslider d-promoted">
<ul class="slides">
<li>
<div>
<img alt="Zdjęcie" src="http://vignette3.wikia.nocookie.net/thecornerclub/images/e/e1/Blast_500x500-1-.jpg/revision/latest?cb=20150213022400" />
<div class="caption-area">
<span class="promoted-d-day-offer">Offer</span>
<span class="promoted-d-title">Title</span>
<span class="promoted-d-caption">Year</span>
<span class="promoted-d-price">Price</span>
</div>
</div>
</li>
<li>
<div>
<img alt="Zdjęcie" src="http://vignette3.wikia.nocookie.net/thecornerclub/images/e/e1/Blast_500x500-1-.jpg/revision/latest?cb=20150213022400" />
<div class="caption-area">
<span class="promoted-d-day-offer">Offer</span>
<span class="promoted-d-title">Title</span>
<span class="promoted-d-caption">Year</span>
<span class="promoted-d-price">Price</span>
</div>
</div>
</li>
</ul>
</div>
</div>
.site_title {
/*text-overflow: ellipsis;*/
overflow: visible;
font-weight: 400;
font-size: 22px;
width: 100%;
color: #ECF0F1 !important;
margin-left: 150px !important;
line-height: 59px;
display: block;
height: 55px;
margin: 0;
padding-left: 10px;
}
<div class="navbar nav_title" style="border: 0;">
<a href="index.html" class="site_title">
<i class="fa fa-paw"></i> <span>Gentellela Alela!</span>
</a>
</div>
I want to make the contents visible if overflowed. I have set overflow:visible but still the extra contents are clipped.
You mean like this?
.site_title {
/*text-overflow: ellipsis;*/
overflow: visible;
font-weight: 400;
font-size: 22px;
width: 100%;
color: #ECF0F1 !important;
line-height: 59px;
display: block;
height: 55px;
margin: 0;
padding: 0;
}
<div class="navbar nav_title" style="border: 0;">
<a href="index.html" class="site_title">
<i class="fa fa-paw"></i> <span>Gentellela Alela!</span>
</a>
</div>