I'm attempting to create transitions on the social media links on https://ollynural.github.io/ but i'm having trouble making it work as expected.
When hovering on each icon, my aim is for the hr bar to smoothly transition both left and right sides to the correct point whilst making it smaller. At the moment it moves the beginning of the bar to the set point of the smaller part and then reduces it smoothly. I'm not really sure how to approach this, i'm mainly experimenting with css and transitions now.
I've made a JSFiddle here as best I can.
.social-links {
margin: 0 auto;
width: 50%;
}
hr {
width: 90%;
border-top: 2px solid #8c8b8b;
transition: width 0.5s ease;
}
#media (min-width: 768px) {
.social-links {
width: 30%;
}
}
.social-links span {
width: 100%;
text-align: center;
font-size: 1.8rem;
margin-top: 15px;
}
#media (min-width: 420px) {
.social-links span {
font-size: 2rem;
margin-top: 25px;
}
}
.fa-github:hover {
color: #64a4df;
}
.github-link:hover ~ .social-line {
width: 7.5%;
margin-left: 9%;
}
.fa-linkedin-square:hover {
color: #64a4df;
}
.linkedin-link:hover ~ .social-line {
width: 7.5%;
margin-left: 34%;
}
.fa-twitter-square:hover {
color: #64a4df;
}
.twitter-link:hover ~ .social-line {
width: 7.5%;
margin-left: 59%;
}
.fa-facebook-square:hover {
color: #64a4df;
}
.facebook-link:hover ~ .social-line {
width: 7.5%;
margin-left: 84%;
}
.social-link {
margin-bottom: 20px;
padding-right: 0px;
padding-left: 0px;
height: 20px;
width: 20px;
background: red;
}
<div class="social-bar">
<div class="col-xs-12">
<div class="social-links">
<div class="col-xs-3 github-link social-link">
<a href="https://github.com/OllyNural" target="github">
<span class="fa fa-github"></span>
</a>
</div>
<div class="col-xs-3 linkedin-link social-link">
<a href="https://www.linkedin.com/in/oliver-nural-43565497" target="linkedin">
<span class="fa fa-linkedin-square"></span>
</a>
</div>
<div class="col-xs-3 twitter-link social-link">
<a href="https://twitter.com/OliverNural" target="twitter">
<span class="fa fa-twitter-square"></span>
</a>
</div>
<div class="col-xs-3 facebook-link social-link">
<a href="https://www.facebook.com/Olly.Nural" target="facebook">
<span class="fa fa-facebook-square"></span>
</a>
</div>
<hr class="social-line">
</div>
</div>
</div>
Thanks, Olly
You are changing two properties here, width and margin-left.
Therefore, you need to set transition both for width (as you did) and for margin-left.
For it to work smoothly, you will need to set a numeric initial value for `margin-left'.
This worked for me:
hr {
margin-left: 5%;
width: 90%;
border-top: 2px solid #8c8b8b;
transition: width 0.5s ease, margin-left 0.5s ease;
}
Related
I'm trying to animate the width of the span inside the an of this link.
The same demo: https://www.khaneyeax.com/en
.lang {
background-color: rgba(255,255,255,0.1);
left: -130px;
top: 400px;
}
.lang a {
padding: 10px;
color: black;
max-width: 0;
display: block;
overflow: hidden;
white-space: nowrap;
transition: max-width 1s ease-in-out;
}
.lang a:hover {
width: 300px;
max-width: 300px;
}
<div id="left">
<img src="https://via.placeholder.com/150">
<div class="position-fixed lang">
Language Persian FA
<a class="english">Language English EN</a>
<a class="search"><i class="fas fa-search"></i> Advanced Search </a>
</div>
</div>
I am making a sidebar and am new to css. I created a div which represents a closed sidebar. It is supposed to only show the icons. Unfortunately the icons come in a misaligned manner inside the div based on their size. How do I fix this?
.sidenav {
height: 492px;
width: 300px;
background-color: #db3d44;
}
.data-icon {
font-size: 45px;
color: black;
opacity: 0.5;
float: left;
margin-left: 9px;
margin-top: 5px;
margin-bottom: 10px;
}
.hamburger {
background-color: transparent;
border-color: transparent;
color: white;
margin-left: 10px;
margin-top: 4px;
font-size: 25px;
}
.hamburger:hover {
color: black;
}
.sidenav-closed {
width: 65px;
float: left;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="sidenav-closed sidenav">
<button class="hamburger data-disappear">☰</button>
<div class="icons-only">
<div class="data-icon">
<i class="fa fa-home"></i>
</div>
<div class="data-icon">
<i class="fa fa-car"></i>
</div>
<div class="data-icon">
<i class="fa fa-home"></i>
</div>
</div>
</div>
The car icon is misaligned here. What's the solution?
You could try to align all the icons to the center so your .data-icon class could look like this:
.data-icon {
font-size: 45px;
color: black;
opacity: 0.5;
display: block;
width: 100%;
text-align: center;
}
Your div elements doesn't have set width and height in CSS - so the icons are strictly aligned inside them.
If you want to vertically center them and learn something new use flexbox:
.icons-only {
display: flex;
flex-direction: column;
align-items: center;
}
and
.data-icon {
...
margin-left:0
}
Your car icon is also a little bit bigger than house - you can a little change it size by add new class to it or use this:
.data-icon:nth-child(2) {
font-size: 40px;
}
This CSS code will take second (=2) element with class .data-icon and set different font size for it
The icons are inline elements so they will be left aligned by default. Add in that the icons are not that same size (this is normal), you get an uneven alignment.
To remedy this, add text-align: center to .icons-only.
Note: Given the layout in the example, it does not appear necessary to float .data-icon to the left.
.sidenav {
height: 492px;
width: 300px;
background-color: #db3d44;
}
.icons-only {
text-align: center;
}
.data-icon {
color: rgba( 0, 0, 0, 0.5 );
font-size: 45px;
}
.hamburger {
background-color: transparent;
border-color: transparent;
color: white;
margin-left: 10px;
margin-top: 4px;
font-size: 25px;
}
.hamburger:hover {
color: black;
}
.sidenav-closed {
width: 65px;
float: left;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="sidenav-closed sidenav">
<button class="hamburger data-disappear">☰</button>
<div class="icons-only">
<div class="data-icon">
<i class="fa fa-home"></i>
</div>
<div class="data-icon">
<i class="fa fa-car"></i>
</div>
<div class="data-icon">
<i class="fa fa-home"></i>
</div>
</div>
</div>
So I've been working on a website (one of my first official ones) and I have been doing it in the Atom editor. I use one of the live preview packages and have built the entire website using that. When I finally got it to a point where I wanted to upload it, I use a host called 000webhost. I upload it and go to the URL, but suddenly my media queries have stopped working. It's very odd because for some reason all of the CSS inside the media query (which sizes it for mobile) has stopped working. The menu button that is used for the mobile menu shows up, as well as the background image used on mobile. However, when I open the file locally or open it in the live preview, everything displays the way it should on mobile vs desktop. I'll post the index.html file and the CSS file to go along with it. Thanks in advance for any help! (btw I know there are lots of posts about media queries not working, but I have looked through at least 15 of them and nothing has helped) ((pardon the probably sloppy code))
/* styles.css: */
html {
overflow: scroll;
overflow-x: hidden;
}
::-webkit-scrollbar {
width: 0px;
background: transparent;
}
::-webkit-scrollbar-thumb {
background: #FF0000;
}
body {
font-family: 'Oswald', sans-serif;
}
/* Links */
a {
text-decoration: none;
color: #000000;
}
a:hover {
color: #808080;
}
a:active {
color: #696969;
}
.white-link {
text-decoration: none;
color: #ffffff;
}
/* Nav */
#nav-bar {
position: fixed;
width: 100%;
left: 0px;
top: 0px;
background-color: #ffffff;
z-index: 2;
box-shadow: 10px 3px 6px #696969;
}
#nav-logo {
display: inline-block;
padding-left: 90px;
opacity: 1;
transition: opacity 0.6s ease;
}
#nav-logo:hover {
opacity: 0.5;
}
#nav-logo:active {
opacity: 0.3;
}
#nav-pages {
position: relative;
top: 50%;
transform: translateY(-35%);
display: inline-block;
font-size: 270%;
padding-left: 50px;
}
#mobile-menu {
display: block;
}
.nav-link {
padding-left: 40px;
padding-right: 40px;
opacity: 1;
transition: opacity 0.6s ease;
}
.nav-link:hover {
opacity: 0.5;
}
.nav-link:active {
opacity: 0.3;
}
.current {
opacity: 0.5;
}
#nav-media {
position: relative;
display: inline-block;
float: right;
margin-right: 30px;
margin-top: 27px;
}
#menu-icon {
display: none;
position: relative;
float: right;
margin-right: 20px;
margin-top: 20px;
padding: 10px;
background-color: #ffffff;
border-radius: 0px, 0px, 0px, 5px;
}
#close-icon {
display: none;
position: absolute;
top: 20px;
right: 20px;
padding: 10px;
}
.nav-link-media {
padding-left: 10px;
padding-right: 10px;
opacity: 1;
transition: opacity 0.6s ease;
}
.nav-link-media:hover {
opacity: 0.5;
}
.nav-link-media:active {
opacity: 0.3;
}
/* Header */
#header-background-image {
width: 102%;
position: relative;
left: -1%;
z-index: -1;
}
#header-background-mobile {
display: none;
}
#header-message {
position: absolute;
text-align: center;
top: 90%;
left: 37%;
font-size: 300%;
color: #808080;
}
/* Content */
#content {
position: relative;
left: -1%;
width: 102%;
background-color: #ffffff;
}
#mobile {
display: none;
}
.section {
width: 100%;
text-align: center;
}
.section-title {
font-size: 400%;
}
.odd {
background-color: #ffffff;
color: #000000;
}
.even {
background-color: #000000;
color: #ffffff;
}
.container {
width: 90%;
display: inline-block;
padding: 4%;
}
.container2 {
width: 25%;
display: inline-block;
padding: 4%;
}
.container3 {
width: 25%;
display: inline-block;
padding: 4%;
}
.container23 {
width: 50%;
display: inline-block;
padding: 4%;
}
.container23-left {
text-align: left;
width: 50%;
display: inline-block;
padding: 4%;
}
.container23-left .container-title, .container23-left .container-text {
text-align: left;
}
.container-title {
text-align: center;
font-size: 350%;
}
.container-text {
text-align: center;
font-size: 170%;
}
/* Slideshows */
#slideshow-arrows {
width: 100%;
display: inline-block;
left: 0px;
bottom: 370px;
}
.left-arrow, .right-arrow {
cursor: pointer;
padding: 16px;
transition: 0.6s ease;
}
.dot {
cursor: pointer;
height: 15px;
width: 15px;
margin: 0 2px;
background-color: #000000;
border-radius: 50%;
display: inline-block;
opacity: 1;
vertical-align: 23px;
transition: opacity 0.6s ease;
}
.active, .dot:hover, .left-arrow:hover, .right-arrow:hover {
opacity: 0.5;
}
/* Banner Slideshow */
#banner-slideshow-image {
width: 75%;
transition: opacity .5s ease-in;
}
#banner-slideshow-image+#banner-slideshow-image {
opacity: 0;
}
/* Avatar Slideshow */
#avatar-slideshow-image {
width: 25%;
transition: opacity .5s ease-in;
}
#avatar-slideshow-image+#avatar-slideshow-image {
opacity: 0;
}
#video-slideshow {
width: 640px;
}
#octocat {
width: 50%;
margin: 0 auto;
}
#portrait {
height: 500px;
}
#desk {
height: 300px;
}
/* Form */
input {
font-size: 120%;
}
label {
font-size: 120%;
}
.text-box {
border: none;
border-bottom: solid 3px #000000;
width: 350px;
}
textarea {
border: none;
border-bottom: solid 3px #000000;
font-size: 120%;
width: 350px;
}
input[type="radio"] {
display: none;
}
input[type="radio"]+label span {
display: inline-block;
width: 20px;
height: 20px;
background: url(images/unchecked.png) center no-repeat;
background-size: 15px 15px;
cursor: pointer;
}
label {
cursor: pointer;
}
input[type="radio"]:checked+label span {
background: url(images/checked.png) center no-repeat;
background-size: 15px 15px;
}
input[type="submit"] {
background-color: transparent;
border: none;
font-size: 150%;
padding: 12px;
cursor: pointer;
font-family: 'Oswald', sans-serif;
border-bottom: solid 3px #000000;
opacity: 1;
transition: opacity .5s ease-in;
}
input[type="submit"]:hover {
opacity: 0.5;
}
input[type="submit"]:active {
opacity: 0.3;
}
/* Mobile */
#media only screen and (max-width: 1024px) {
#nav-bar {
background-color: transparent;
box-shadow: none;
}
#nav-logo, #nav-pages, .nav-link, #nav-media {
display: block;
float: none;
}
#nav-logo {
width: 50%;
margin: 0 auto;
padding: 0px;
padding-bottom: 70px;
text-align: center;
}
#nav-pages {
width: 90%;
margin: 0 auto;
text-align: center;
font-size: 200%;
padding-left: 0px;
}
#nav-media {
width: 70%;
margin: 0 auto;
text-align: center;
}
#menu-icon {
display: block;
}
#close-icon {
display: block;
}
#header-background-image {
display: none;
}
#header-background-mobile {
display: block;
position: relative;
z-index: -1;
left: 0px;
top: 0px;
width: 100%;
}
#header-message {
display: none;
}
#content {
position: relative;
left: -1%;
width: 102%;
background-color: #ffffff;
}
#desktop {
display: none;
}
#mobile {
display: block;
}
#mobile-menu {
display: none;
z-index: 2;
background-color: #ffffff;
width: 100%;
}
.section {
width: 100%;
text-align: center;
}
.section-title {
font-size: 300%;
}
.odd {
background-color: #ffffff;
color: #000000;
}
.even {
background-color: #000000;
color: #ffffff;
}
.container {
width: 90%;
display: inline-block;
padding: 4%;
}
.container2 {
width: 90%;
display: inline-block;
padding: 4%;
}
.container3 {
width: 90%;
display: inline-block;
padding: 4%;
}
.container23 {
width: 90%;
display: inline-block;
padding: 4%;
}
.container23-left {
width: 90%;
display: inline-block;
padding: 4%;
}
.container23-left .container-title, .container23-left .container-text {
text-align: center;
}
.container-title {
font-size: 300%;
}
.container-text {
font-size: 140%;
}
.dot {
display: none;
}
#banner-slideshow-image {
width: 90%;
}
#avatar-slideshow-image {
width: 90%;
}
#video-slideshow {
width: 90%;
}
#portrait {
width: 90%;
height: auto;
}
#desk {
width: 90%;
height: auto;
}
.text-box {
width: 90%;
}
textarea {
width: 90%;
}
}
<!-- index.html: -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Home | NRDesign</title>
<link rel="shortcut icon" type="image/png" href="files/images/logo-dark.png">
<link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet">
<link rel="stylesheet" type="text/css" title="Main" href="files/styles.css">
<meta name="viewport" content="width=device-width">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
</head>
<body>
<!--- Nav --->
<div id="nav">
<div id="nav-bar">
<div id="mobile-menu">
<div id="nav-logo"><img src="files/images/logo-dark.svg" width="90px" height="90px" alt="nav-logo" /></div>
<div id="close-icon"><img src="files/images/close.svg" width="40px" height="40px" /></div>
<div id="nav-pages">
<a class="nav-link current" href="#">Home</a>
<a class="nav-link" href="about.html">About Me</a>
<a class="nav-link" href="portfolio.html">My Portfolio</a>
<a class="nav-link" href="contact.html">Contact Me</a>
</div>
<div id="nav-media">
<a class="nav-link-media" href="https://twitter.com/ngregrichardson" target="_blank"><img src="files/images/twitter-logo.svg" width="40px" height="40px" alt="twitter-logo" /></a>
<a class="nav-link-media" href="https://www.youtube.com/channel/UCUB_cxZFm_72B5AVvZpJpYg" target="_blank"><img src="files/images/youtube-play-button.svg" width="40px" height="40px" alt="youtube-logo" /></a>
<a class="nav-link-media" href="https://github.com/ngregrichardson" target="_blank"><img src="files/images/github-logo.svg" width="40px" height="40px" alt="github-logo" /></a>
</div>
</div>
<div id="menu-icon"><img src="files/images/menu.svg" width="40px" height="40px" /></div>
</div>
</div>
<!-- Header -->
<div id="header">
<div id="header-background">
<img id="header-background-image" src="files/images/header-background.jpg" alt="header-background" />
</div>
<div id="header-background">
<img id="header-background-mobile" src="files/images/header-background-mobile.jpg" alt="header-background" />
</div>
</div>
<!-- Content -->
<div id="content">
<div id="desktop">
<div class="section odd">
<div class="container3">
<div class="container-title">Graphic Design</div>
<div class="container-text">To create logos, banners, and avatars, I use a mixture of Cinema 4D, Adobe Photoshop, and Adobe Illustrator.</div>
</div>
<div class="container3">
<div class="container-title">About Me</div>
<div class="container-text">Welcome! My name is Noah Richardson and I am a 17 year old graphic designer, programmer, and comuter enthusiest. I created this website to make everything I've worked on public so that others can use it in their own projects and to learn. Enjoy!</div>
</div>
<div class="container3">
<div class="container-title">Programming</div>
<div class="container-text">Through lots of self-learning, I have taught myself upwards of sixteen programming languages, mainly including Java, Python, and C#.</div>
</div>
</div>
</div>
<div id="mobile">
<div class="section odd">
<div class="container3">
<div class="container-title">About Me</div>
<div class="container-text">Welcome! My name is Noah Richardson and I am a 17 year old graphic designer, programmer, and comuter enthusiest. I created this website to make everything I've worked on public so that others can use it in their own projects and to learn. Enjoy!</div>
</div>
<div class="container3">
<div class="container-title">Graphic Design</div>
<div class="container-text">To create logos, banners, and avatars, I use a mixture of Cinema 4D, Adobe Photoshop, and Adobe Illustrator.</div>
</div>
<div class="container3">
<div class="container-title">Programming</div>
<div class="container-text">Through lots of self-learning, I have taught myself upwards of sixteen programming languages, mainly including Java, Python, and C#.</div>
</div>
</div>
</div>
<div class="section even">
<div class="container2">
<div class="container-title">Visual Effects</div>
<div class="container-text">At the start of my YouTube channel, I began to edit my own videos and try different visual effect creations. I began to improve my workflow by editing videos with Sony Vegas Pro and using Adobe After Effects to create special effects.</div>
</div>
<div class="container2">
<div class="container-title"></div>
<div class="container-text"></div>
</div>
<div class="container2">
<div class="container-title">Visual Effects</div>
<div class="container-text">To work with visual effects and video editing I use Sony Vegas Pro 14, Adobe After Effects, Adobe Premiere Pro, and Cinema 4D.</div>
</div>
</div>
<div class="section odd">
<div class="section-title">My Portfolio</div>
<div id="slideshow">
<img id="banner-slideshow-image" class="fade" src="files/images/slideshows/banners/avay-banner.jpg" alt="banner-slideshow-image" />
<div id="slideshow-arrows">
<img id="banner-left-arrow" class="left-arrow fade" src="files/images/slideshows/left-arrow.png" width="30px" height="30px" onclick="plusBanner(-1)" />
<span class="dot bannerDot active" onclick="currentBanner(0)"></span>
<span class="dot bannerDot" onclick="currentBanner(1)"></span>
<span class="dot bannerDot" onclick="currentBanner(2)"></span>
<span class="dot bannerDot" onclick="currentBanner(3)"></span>
<span class="dot bannerDot" onclick="currentBanner(4)"></span>
<span class="dot bannerDot" onclick="currentBanner(5)"></span>
<span class="dot bannerDot" onclick="currentBanner(6)"></span>
<span class="dot bannerDot" onclick="currentBanner(7)"></span>
<span class="dot bannerDot" onclick="currentBanner(8)"></span>
<span class="dot bannerDot" onclick="currentBanner(9)"></span>
<span class="dot bannerDot" onclick="currentBanner(10)"></span>
<span class="dot bannerDot" onclick="currentBanner(11)"></span>
<span class="dot bannerDot" onclick="currentBanner(12)"></span>
<span class="dot bannerDot" onclick="currentBanner(13)"></span>
<span class="dot bannerDot" onclick="currentBanner(14)"></span>
<span class="dot bannerDot" onclick="currentBanner(15)"></span>
<span class="dot bannerDot" onclick="currentBanner(16)"></span>
<span class="dot bannerDot" onclick="currentBanner(17)"></span>
<span class="dot bannerDot" onclick="currentBanner(18)"></span>
<span class="dot bannerDot" onclick="currentBanner(19)"></span>
<span class="dot bannerDot" onclick="currentBanner(20)"></span>
<img id="banner-right-arrow" class="right-arrow fade" src="files/images/slideshows/right-arrow.png" width="30px" height="30px" onclick="plusBanner(1)" />
</div>
</div>
</div>
</div>
</div>
<script src="jquery-3.3.1.min.js" type="text/javascript"></script>
<script src="index.js" type="text/javascript"></script>
<script src="mobile.js" type="text/javascript"></script>
</body>
</html>
The files are most likely cached.
You can veryfy this by opening the inspector F12, go to the Network tab and do an normal refresh of the page. In the size column, you will see either the file's size or something like (From disk cache).
The simple way to solve this locally is to clear your device's cache.
If you are running Google Chrome, open your website and open inspector F12, then click the refresh icon and select Empty Cache and hard reload.
Remember, this will only update the page for you. If another person has also visited the site before your change, they will most likely also have the site cached.
You can change what files should be cached and for how long by editing your .htaccess file. This simply tells the visitors browser how long it should wait until fetching the resource again.
Example caching-control:
If you edit a media-query and publish it to your site as a css file. This will not be "live" at your visitors before 1 month after they first visited your site / their cache was renewed.
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##
I'm building a panel for a front end system, but I got an annoying problem.
I am not that good with CSS. This is what happens:
This is my HTML code:
#main #myTopMenu #iconBar {
margin-right: 10px;
float: right;
}
#main #myTopMenu #iconBar a {
display: inline-block;
margin-left: 30px;
color: white;
}
#main #myTopMenu #iconBar .optionsContainer {
line-height: 55px;
}
#main #myTopMenu #iconBar .optionsContainer img {
vertical-align: middle;
position: relative;
}
#main #myTopMenu #iconBar .valueWithOption {
background-color: #59a632;
height: 25px;
width: 35px;
position: absolute;
top: 10px;
margin-left: 27px;
border-radius: 4px;
}
#main #myTopMenu #iconBar .valueWithOption span {
background-color: blue;
width: 100%;
height: 100%;
}
<div id="iconBar">
<a href="#">
<div class="optionsContainer">
<img src="images/icons/message.png">
<div class="valueWithOption">
<span>5</span>
</div>
</div>
</a>
<a href="#">
<div class="optionsContainer"><img src="images/icons/bell.png">
<div class="valueWithOption"><span>5</span></div>
</div>
</a>
<a href="#">
<div class="optionsContainer"><img src="images/icons/settings.png"></div>
</a>
</div>
Also do you guys have tips to make it so that the width of the green box expands so that the value in the green box always fits properly.
I made some significant changes to your codes for expected results. See snippet
#iconBar {
margin-right: 10px;
float: right;
}
#iconBar a {
display: inline-block;
margin-left: 30px;
color: white;
}
#iconBar .optionsContainer img {
vertical-align: middle;
position: relative;
}
#iconBar .valueWithOption {
background-color: #59a632;
padding: 5px;
top: 10px;
border-radius: 4px;
position: relative;
top: -10px;
display:inline-block
}
#iconBar .valueWithOption span {
background-color: blue;
width: 100%;
height: 100%;
}
<br>
<br>
<div id="iconBar">
<a href="#">
<div class="optionsContainer">
<img src="images/icons/message.png">
<div class="valueWithOption">
<span>5</span>
</div>
</div>
</a>
<a href="#">
<div class="optionsContainer"><img src="images/icons/bell.png">
<div class="valueWithOption"><span>500</span></div>
</div>
</a>
<a href="#">
<div class="optionsContainer"><img src="images/icons/settings.png"></div>
</a>
</div>
I've created a left navigation bar using buttons. I'm trying to reduce the hyperlink area to just the background image. Also, another issue I'm having is the elements overlaying the background image are taking precedence over the hyperlink, so the button is not actually clickable. Page for reference
http://www.auburn.edu/administration/facilities/home-page/index.html
Hyperlink area
Here's the background image area
.img-responsive {
display: block;
padding: 0;
margin: 0;
}
.background:hover .head {
color: #d76e08;
}
.overlay {
position: absolute;
z-index: 1;
top: 0;
left: 0;
color: white;
}
.icon {
padding-top: 15px;
padding-left: 40px;
}
.head {
margin-top: -75px;
padding-left: 120px;
}
.content {
margin-top: -5px;
padding-left: 120px;
padding-right: 35px;
}
<div class="row">
<div class="col-sm-12">
<div class="background">
<a href="../Collin/misc/issues/index.html">
<img alt="background" class="img-responsive" src="buttons/images/button.png" />
</a>
<div class="overlay">
<div class="icon">
<img alt="test" class="img-responsive" src="buttons/images/info-icon.png" />
</div>
<p class="head">Ask Facilities</p>
<p class="content">Here will be text about the button. .</p>
</div>
</div>
</div>
</div>
I'm trying to reduce the hyperlink area to just the background image.
Your markup is incredibly complex for what you are displaying.
You could have something like:
<ul>
<li>
<a>
<h2></h2>
<p></p>
</a>
</li>
<li>
<a>
<h2></h2>
<p></p>
</a>
</li>
</ul>
and add the image and the gradient using CSS.
I would use a single link tag for your button and leverage CSS gradients for the background:
* {
box-sizing: border-box;
}
body {
font-family: sans-serif;
}
.button {
background-image: linear-gradient(to bottom, #3D85C6, #07355F 50%, #07355F);
background-size: 100% 200%;
border-radius: 4px;
color: #fff;
display: block;
padding: 10px;
text-decoration: none;
transition: all 150ms ease-in-out;
}
.button:hover,
.button:focus,
.button:active {
background-position: 0 50%;
}
.button-icon {
float: left;
margin-right: 15px;
}
.button-content {
overflow: hidden;
}
.button-title {
font-size: 18px;
font-weight: bold;
}
.button-description {
font-size: 16px;
}
<a class="button" href="../Collin/misc/issues/index.html">
<div class="button-icon">
<img src="http://satyr.io/72/white?brand=github" alt=""/>
</div>
<div class="button-content">
<p class="button-title">Ask Facilities</p>
<p class="button-description">Here will be text about the button…</p>
</div>
</a>
Also here http://jsbin.com/rikisemawe/edit?html,css,output
The elements in OP were stacked in the markup, there were no nested components of the button. That would explain the unusual position coords and large padding.
Instead of <img>, background-image is used. Changed some of the tags to a real <button>, <h4> instead of <p>, etc.
SNIPPET
.button {
position: relative;
min-width: 350px;
max-width: 100%;
min-height: 95px;
height: auto;
padding: 5px 10px;
border: 0 none transparent;
border-radius: 6px;
background: url(http://www.auburn.edu/administration/facilities/home-page/buttons/images/button.png)no-repeat;
background-size: cover;
}
.background:hover .head {
color: #d76e08;
}
.text {
padding: 0 5px;
position: absolute;
left: 85px;
top: 5px;
text-align: left;
color: #def;
text-decoration: none;
}
.button:hover,
.text:hover {
text-decoration: none;
color: #def;
}
.button:hover .head {
color: gold;
}
.icon {
width: 75px;
height: 75px;
position: absolute;
top: calc(50% - 37.5px);
background: url(http://www.auburn.edu/administration/facilities/home-page/buttons/images/service-icon.png)no-repeat;
}
<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="row">
<div class="col-sm-12">
<button class="button">
<div class="icon"></div>
<a class='text'>
<h4 class="head">Ask Facilities</h4>
<p class="content">Here will be text about the button.</p>
</a>
</button>
</div>
</div>