Centering icon font in css circle, inside of parent - html

Ok so I have 3 css circles with icon fonts centered inside of them, now I cant for the life of me get it centered inside of its parent. Also instead of lining up they are stacking on top of each other, I used float: left to fix this but it messed up my whole hover.
Take a look here, just go to portfolio section and hover over one of the members.
How it is suppose to look:
How it looks:
HTML:
<ul class="img-list">
<li>
<img src="img/team-member-1.jpg" alt="...">
<span class="text-content">
<span>
<div class="social-icon-holder">
<span class="ion-social-twitter social-icon"></span>
</div>
<div class="social-icon-holder">
<span class="ion-social-facebook social-icon"></span>
</div>
<div class="social-icon-holder">
<span class="ion-social-dribbble social-icon"></span>
</div>
Johnathan Adams
<p>Developer</p>
</span>
</span>
</li>
</ul>
CSS:
/* =Team
-------------------------------------------------------------- */
.team {
padding: 180px 0 180px 0;
}
.team img {
width: 100%;
height: 100%;
}
ul.img-list {
list-style-type: none;
padding: 0;
}
ul.img-list li {
display: inline-block;
position: relative;
height: 350px;
}
span.text-content {
background: rgba(39,39,39,0.75);
color: white;
cursor: pointer;
display: table;
left: 0;
position: absolute;
top: 0;
opacity: 0;
width: 100%;
height: 100%;
}
span.text-content span {
display: table-cell;
text-align: center;
vertical-align: middle;
}
ul.img-list li:hover span.text-content {
opacity: 1;
-webkit-transition: opacity 500ms;
-moz-transition: opacity 500ms;
-o-transition: opacity 500ms;
transition: opacity 500ms;
}
.team span p {
font-family: 'Montserrat', sans-serif;
text-transform: uppercase;
font-size: 14px;
color: #a5a5a5;
}
.social-icon {
font-size: 12px;
color: #fff;
margin: 0 auto;
display: table-cell;
vertical-align: middle;
}
.social-icon-holder {
border: 2px solid #fff;
border-radius: 50%;
width: 30px;
height: 30px;
display: table;
}
.social-icon-holder:hover {
background-color: #fff;
cursor: pointer;
}
.social-icon-holder:hover .social-icon {
color: #272727;
cursor: pointer;
-webkit-transition: color 0.5s ease;
}

Wrap a <p> tag around the team members name to make it a block element and essentially put it on a new line.
Then, in .social-icon-holder{
change
display:table;
to
display:inline-block;
or
display:inline-table;
JsFiddle
For this JsFiddle, I jut used a placeholder background image.
To get the social icons center, I did this:
.social-icon {
font-size: 12px;
color: #fff;
display: block;
text-align:center;
width:30px;
height:30px;
}
JsFiddle

you have to remove display :table from the class .social-icon-holder and then you may add display: table-cell; property.
also to align the icons inside the circle you can add font-size and a little bit padding.
HEre I've just added for facebook icon, but you can apply it on .social-icon so apply for all icons.
.ion-social-facebook:before {
content: "\f231";
font-size: 2em; /*Added line this will increase the icon size*/
padding-left: .4em;
}

from my comment: http://jsfiddle.net/h7kJS/ full result : http://jsfiddle.net/h7kJS/2/embedded/result/
.social-icon-holder can be displayed as inline-table (inline-block+line-height works too).
Image should be in absolute under .text-content to make things easier :below: update of your CSS (where .team was removed for .img-list )
/* =Team
-------------------------------------------------------------- */
.img-list {/* update */
padding: 180px 0 180px 0;
}
.img-list img {/* update */
width: 100%;
height: 100%;
position:absolute;/* update */
z-index:0;/* update */
}
ul.img-list {
list-style-type: none;
padding: 0;
}
ul.img-list li {
display: inline-block;
position: relative;
height: 350px;
width:350px;/* update */
}
span.text-content {
background: rgba(39,39,39,0.75);
color: white;
cursor: pointer;
display: table;
left: 0;
top: 0;
opacity: 0;
width: 100%;
height: 100%;
}
span.text-content span {
display: table-cell;
text-align: center;
vertical-align: middle;
height:100%;
width:100%;
}
ul.img-list li:hover span.text-content {
opacity: 1;
transition: opacity 500ms;
position:relative;/* update */
}
.team span p {
font-family: 'Montserrat', sans-serif;
text-transform: uppercase;
font-size: 14px;
color: #a5a5a5;
}
.social-icon {
font-size: 12px;
color: #fff;
margin: 0 auto;
display: table-cell;
vertical-align: middle;
}
.social-icon-holder {
border: 2px solid #fff;
border-radius: 50%;
width: 30px;
height: 30px;
display: inline-table;/* update */
}
.social-icon-holder:hover {
background-color: #fff;
cursor: pointer;
}
.social-icon-holder:hover .social-icon {
color: #272727;
cursor: pointer;
transition: color 0.5s ease;
}

Is it ok ? try this code
.social-icon-holder {
border: 2px solid #FFFFFF;
border-radius: 50%;
height: 30px;
width: 30px;
display: block;
margin: 0 auto;
}

Try doing this:
<span>
<div class="social">
<div class="social-icon-holder">
<span class="ion-social-twitter social-icon"></span>
</div>
<div class="social-icon-holder">
<span class="ion-social-twitter social-icon"></span>
</div>
<div class="social-icon-holder">
<span class="ion-social-twitter social-icon"></span>
</div>
</div>
</span>
--- stylesheet --
.social div{
display: inline-block;
}
.social-icon{
padding: 8px 10px;
}

Related

How could I change this CSS to make the dropdown effect less buggy?

I provided my CSS and HTML down below. I am trying to finish off my dropdown, but there's an issue with it that makes the transition not so smooth. It's hard to explain with words on what it's doing.
I have tried changing the display, max-height, padding, and margin but there have been no results. Perhaps I need to add some JavaScript to it rather than CSS? Any suggestions or problems that can be pointed out will be great.
#navigation {
height: 100px;
padding: 10px 3px 3px;
background-color: #FFF;
margin-bottom: 210px;
border-radius: 5px;
}
#nav-container {
display: table;
margin: 10px auto;
}
#nav-items {
list-style-type: none;
margin-left: -45px;
margin-top: -26px;
}
#nav-items li {
display: inline-block;
vertical-align: top;
width: 400px;
}
/* nav-dropdown */
#dropdown {
display: block;
position: absolute;
text-align: center;
width: 300px;
height: 50px;
}
#dropdown p {
font-family: 'Work Sans', sans-serif;
font-size: 35px;
letter-spacing: 5px;
display: table-cell;
margin: 0;
cursor: pointer;
background-color: transparent;
text-align: center;
}
#extensions {
display: table;
border-collapse: separate;
border-spacing: 40px;
height: 50px;
width: 350px;
}
.label {
font-family: 'Work Sans', sans-serif;
font-size: 35px;
letter-spacing: 5px;
text-align: center;
position: absolute;
width: 300px;
}
#dropdown-content {
position: absolute;
margin: 0 auto;
opacity: 0;
width: 300px;
height: 50px;
background-color: #C9C9C9;
border-radius: 8px;
box-shadow: 1px 1px 50px 0px white;
z-index: 1;
overflow-y: hidden;
transition-property: all;
transition-duration: 0.5s;
transition-timing-function: cubic-bezier(0, 1, 0.5, 1);
}
.nav-dropdown-container {width: 350px;height: 800px;}
#dropdown-content p {
font-size: 20px;
font-family: 'Work Sans', sans-serif;
font-size: 30px;
letter-spacing: 2px;
}
#dropdown-content:hover {
opacity: 1;
max-height: 500px;
padding-top: 1em;
padding-bottom: 1em;
margin-top: 50px;
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
display: block;
}
#dropdown-content:hover p {
display: block;
text-decoration: none;
transition: 0.5s;
}
#dropdown-content p {display: none;}
#dropdown-link {color: white;}
#dropdown-link:link {
color: white;
text-decoration: none;
}
#dropdown-link:hover {
color: lightgrey;
}
<nav id="navigation">
<div id="nav-container">
<ul id="nav-items">
<li>
<div id="extensions">
<div class="nav-dropdown-container">
<div id="dropdown">
<p class="label">TEST</p>
<div id="dropdown-content">
<p><a id="dropdown-link" href="hello.html">HELLO</a></p>
<p><a id="dropdown-link" href="world.html">WORLD</a></p>
</div>
</div>
</div>
</div>
</li>
</ul>
</div>
</nav>
As stated in the comments, the reason is because when the :hover state is triggered on #dropdown-content, the mouse cursor quickly enters and leaves the element causing the state to be quickly toggled on and off repeatedly, resulting in a janky transition.
The fastest fix is this: you should change your selectors so that you bind the :hover state to the nearest common ancestor of both the label AND the dropdown content, i.e. #dropdown.
So you should change this:
#dropdown-content:hover { ... }
#dropdown-content:hover p { ... }
...to this:
#dropdown:hover #dropdown-content { ... }
#dropdown:hover #dropdown-content p { ... }
This is of course a stop-gap solution since I find your markup unnecessarily bloated in order to achieve a simple dropdown effect.
#navigation {
height: 100px;
padding: 10px 3px 3px;
background-color: #FFF;
margin-bottom: 210px;
border-radius: 5px;
}
#nav-container {
display: table;
margin: 10px auto;
}
#nav-items {
list-style-type: none;
margin-left: -45px;
margin-top: -26px;
}
#nav-items li {
display: inline-block;
vertical-align: top;
width: 400px;
}
/* nav-dropdown */
#dropdown {
display: block;
position: absolute;
text-align: center;
width: 300px;
height: 50px;
}
#dropdown p {
font-family: 'Work Sans', sans-serif;
font-size: 35px;
letter-spacing: 5px;
display: table-cell;
margin: 0;
cursor: pointer;
background-color: transparent;
text-align: center;
}
#extensions {
display: table;
border-collapse: separate;
border-spacing: 40px;
height: 50px;
width: 350px;
}
.label {
font-family: 'Work Sans', sans-serif;
font-size: 35px;
letter-spacing: 5px;
text-align: center;
position: absolute;
width: 300px;
}
#dropdown-content {
position: absolute;
margin: 0 auto;
opacity: 0;
width: 300px;
height: 50px;
background-color: #C9C9C9;
border-radius: 8px;
box-shadow: 1px 1px 50px 0px white;
z-index: 1;
overflow-y: hidden;
transition-property: all;
transition-duration: 0.5s;
transition-timing-function: cubic-bezier(0, 1, 0.5, 1);
}
.nav-dropdown-container {
width: 350px;
height: 800px;
}
#dropdown-content p {
font-size: 20px;
font-family: 'Work Sans', sans-serif;
font-size: 30px;
letter-spacing: 2px;
}
#dropdown:hover #dropdown-content {
opacity: 1;
max-height: 500px;
padding-top: 1em;
padding-bottom: 1em;
margin-top: 50px;
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
display: block;
}
#dropdown:hover #dropdown-content p {
display: block;
text-decoration: none;
transition: 0.5s;
}
#dropdown-content p {
display: none;
}
#dropdown-link {
color: white;
}
#dropdown-link:link {
color: white;
text-decoration: none;
}
#dropdown-link:hover {
color: lightgrey;
}
<nav id="navigation">
<div id="nav-container">
<ul id="nav-items">
<li>
<div id="extensions">
<div class="nav-dropdown-container">
<div id="dropdown">
<p class="label">TEST</p>
<div id="dropdown-content">
<p><a id="dropdown-link" href="hello.html">HELLO</a></p>
<p><a id="dropdown-link" href="world.html">WORLD</a></p>
</div>
</div>
</div>
</div>
</li>
</ul>
</div>
</nav>

Element after other Element higher on page?

I can't get an element to go where I want it to. I am only having this problem because of the way I did my header. I applied position: absolute. You can see an example here: http://jacobgasser.com and you can find all the code on there, or you can read down a little farther and I put it there.
I want the text in the top left of the page to be on the white part of the page
Here is the index.html
<body onload="loadUp();">
<div class="menu">
<a href="https://github.com/jacobgasser" target="_blank"><div
class="menuItem">Projects</div></a>
</div>
<div class="titleBG">
<h1 class="title" onmouseover="coolThing();"onmouseout="notCoolThing();">Jacob Gasser</h1>
</div>
<div class="article">
<div class="articleHead">Who am I?</div>
</div>
<script src="scripts/main.js"></script>
</body>
Here is main.css
body {
margin:0;
padding:0;
}
.title {
color: white;
text-align: center;
font-size: 1000%;
opacity: 0;
-webkit-transition: 0.2s;
}
a {
text-decoration: none;
color: inherit;
}
.article {
font-family: "Arial";
display: inline-block;
padding: 5px 10px 5px 10px;
margin: 5px 10px 5px 10px;
text-align: center;
position: relative;
}
.articleHead {
display: inline-block;
padding: 5px 10px 5px 10px;
margin: 5px 10px 5px 10px;
}
.menu {
display: block;
color: white;
float: right;
margin-right: 10px;
margin-top: 5px;
opacity: 0;
}
.menuItem {
font-size: 400%;
display: block;
padding-left: 20px;
padding-right: 20px;
-webkit-transition: 0.2s;
border-radius: 5px;
}
.menuItem:hover {
background-color: white;
color: black;
cursor: pointer;
-webkit-transition: 0.2s;
}
.titleBG {
background-color: #23272A;
display: block;
width: 100%;
z-index: -1;
position: fixed;
top: 0;
}
::selection {
color: #23272A;
background-color: white;
}
::-moz-selection {
color: #23272A;
background-color: white;
}
#font-face {
font-family: lemon;
src: url("fonts/LemonMilk.otf");
}
#font-face {
font-family: cavs;
src: url("fonts/CaviarDreams.ttf");
}
A simple solution to this issue is to remove the position: fixed; top: 0; and adjust the margin-top and margin-bottom of the page. Just change the CSS for .titleBG and .title to be the following:
.titleBG {
background-color: #23272A;
display: block;
width: 100%;
z-index: -1;
}
.title {
color: white;
text-align: center;
font-size: 1000%;
opacity: 0;
-webkit-transition: 0.2s;
margin: 0 /* You can add a margin-left or margin-right if you want, or even margin-bottom, just keep the margin-top at 0*/;
}
This will give you the following result:

How to add a button and text over image when hovering (HMTML/CSS/Bootstrap 3)

I am able to display two span text elements over the image when I hover over with my cursor successfully. But I am having trouble placing a button that is centered over the image, below the project name. Any help would be appreciated. I should also note the button that I want to use is from a Bootstrap 3 class.
Here is a demo: https://jsfiddle.net/oo1xx006/3/
Here is an example of what I want to create: http://www.devonstank.com/
HTML:
<div class="latest_projects">
<!-- My latest projects -->
<h1>My latest projects</h1>
<br>
<ul class="projects-list">
<li>
<img src="img/mudmat-global-model.jpg" alt="DOF Mudmat Lowering" width="380px" height="380px"/>
<span class="text-content">
<span class="project-type"><i>Project Type</i></span>
<span class="project-name">Project Name</span>
<!-- <span>View project</span> -->
</span>
</li>
</ul>
<br>
View more projects
</div>
CSS:
body {
padding-top: 0;
font-family: 'PT Sans', sans-serif;
background-color: white;
}
h1 {
/* margin: 15px 0;*/
font-size: 1.9em;
font-weight: normal;
color: #000;
line-height: 120%;
text-align: center;
}
h2 {
font-size: 1.3em;
margin: -5px 0 0;
font-weight: normal;
color: #000;
text-align: center;
}
a {
text-decoration: none;
color: #000;
font-weight: bold;
}
a:hover {
text-decoration: none;
}
p {
line-height: 200%;
padding: 0 10% 0 10%;
font-size: 1.1em;
text-align: center;
}
.btn-default {
border-color: #000;
border-radius: 0;
border-width: 2px;
color: #000;
font-size: 1.5em;
}
.btn-default:hover {
color: #fff;
background-color: #000;
border-color: #000;
border-radius: 0;
border-width: 2px;
}
img {
max-width: 100%;
}
/************************************
HOME
************************************/
.latest_projects {
text-align: center;
max-width: 1200px;
margin: 0 auto;
}
.latest_projects p {
margin: 0;
color: transparent;
}
.fluid-container img {
height: 350px;
width: 350px;
margin-bottom: 20px;
vertical-align: middle;
}
/*******Project Images******/
ul.projects-list {
list-style-type: none;
margin: 0;
padding: 0;
text-align: center;
}
ul.projects-list li {
display: inline-block;
height: 380px;
position: relative;
width: 380px;
}
span.text-content {
background: rgba(0,0,0,0.5);
color: white;
cursor: pointer;
display: table;
height: 380px;
left: 0;
position: absolute;
top: 0;
width: 380px;
}
span.text-content span {
display: table-cell;
text-align: center;
vertical-align: middle;
}
span.text-content {
background: rgba(0,0,0,0.5);
color: white;
cursor: pointer;
display: table;
height: 380px;
left: 0;
position: absolute;
top: 0;
width: 380px;
opacity: 0;
}
ul.projects-list li:hover span.text-content {
opacity: 1;
}
span.text-content {
background: rgba(0,0,0,0.5);
color: white;
cursor: pointer;
display: table;
height: 380px;
left: 0;
position: absolute;
top: 0;
width: 380px;
opacity: 0;
-webkit-transition: opacity 500ms;
-moz-transition: opacity 500ms;
-o-transition: opacity 500ms;
transition: opacity 500ms;
}
span.project-type {
position: absolute;
text-align: center;
/*margin: 25px 0;*/
padding: 120px;
width: 380px;
vertical-align: middle;
font-size: 1.7em;
}
span.project-name {
font-size: 2.5em;
}
span.view-project {
position: absolute;
text-align: center;
/*margin: 25px 0;*/
padding: 10px;
width: 380px;
vertical-align: middle;
font-size: 1.7em;
}
You can do that with Javascript. Basically you have a container, inside which you need to see/use extra content if you hover on it. I suggest that you should add the needed html, but with display: none; CSS rule, and then you need to show it when the user hovers the container and hide it if the use leaves the container. This is how you can do it with jQuery:
$(".yourcontainerclass").mouseenter(function() {
$(this).find(".yourinnerclass").hide();
});
$(".yourcontainerclass").mouseout(function() {
$(this).find(".yourinnerclass").show();
});

how to place css div container "text-align: center ;"

In my css I have the following :
style.css
* {
margin: 0;
padding: 0;
}
body {
width: 100%;
font-family: 'Cabin', sans-serif;
}
/*.clear {
clear: both;
}*/
.clear:after {
display: block;
clear: both;
visibility: hidden;
content: "";
height: 0;
}
/* HEADER BLOCK */
.header-background {
padding-top: 50px;
}
.header-background > div:first-child {
width: 100%;
background: #232323;
}
.header {
background: #232323;
color: #B2B2B2;
width: 80%;
margin: auto;
}
.header a {
text-decoration: none;
color: white;
}
.header a:active {
color: #19A3A3;
}
#nav {
position: relative;
display: block;
height: 55px;
line-height: 55px;
width: 100%;
max-width: none;
margin: 0;
background: #333;
z-index: 1;
border-bottom: 1px solid #666;
font-weight: 600;
font-family: helvetica, arial, sans-serif;
font-size: 14px;
}
#nav, #nav * {
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
}
.nav-item {
color: #fff;
text-transform: uppercase;
text-decoration: none;
}
/* Desktop */
#desktop-nav .nav-item {
display: block;
padding: 0 20px;
float: right;
-webkit-transition: color 200ms linear;
-moz-transition: color 200ms linear;
-ms-transition: color 200ms linear;
-o-transition: color 200ms linear;
transition: color 200ms linear;
}
#desktop-nav .nav-item:hover, #desktop-nav .nav-item:active {
opacity: 0.7;
}
And I have the following html:
<body>
<div class="header-background">
<!-- <div> -->
<div id="nav">
<nav id="desktop-nav">
<a class="nav-item" href="#1">Github</a>
<a class="nav-item" href="#2">About</a>
<a class="nav-item" href="#3">Community</a>
<a class="nav-item" href="#4">Docs</a>
</nav>
</div>
</div>
</body>
Now I am getting the view:--
But I want the view like :--
The menu should be in the middle. I have used text-align: center; but it is not executing. What I am doing wrong?
Change this
#nav {
margin: 0 auto; //added this
width: 400px; //added this
position: relative;
display: block;
height: 55px;
line-height: 55px;
max-width: none;
background: #333;
z-index: 1;
border-bottom: 1px solid #666;
font-weight: 600;
font-family: helvetica, arial, sans-serif;
font-size: 14px;
}
Fiddle: https://jsfiddle.net/fuehunfz/
Currently the #desktop-nav is centered but it's 100% wide so you need to shrink-wrap it by making it inline-block.
Then text-align:center on the #nav` will center it.
#nav {
text-align: center;
}
#desktop-nav {
display: inline-block;
}
JSfiddle Demo
Use following CSS Style in CSS class
margin: 0 auto;

How do you make an IMAGE move independent of the elements around it using CSS3 Transition?

I'm trying to use a CSS3 transition to make the image inside this <div> move 10 pixels upward when the <div> is hovered over. It works great in Firefox, but when I view it in Chrome and Safari, the <h3> and <p> elements jitter up and down a bit.
This is my CSS:
.feature-table #box {
width: 325px;
height: 372px;
margin-right: 20px;
float: left;
}
.feature-table a {
display: block;
width: 325px;
height: 372px;
}
.feature-table a img {
display: block;
margin-left: auto;
margin-right: auto;
padding-top: 54px;
padding-bottom: 40px;
-moz-transition: all 0.3s linear;
-webkit-transition: all 0.3s linear;
transition: all 0.3s linear;
}
.feature-table a: hover img {
padding-top: 44px;
padding-bottom: 50px;
}
.feature-table a h3 {
font-family: 'GothamBold', sans-serif;
font-size: 30px;
color: #3d3d3d;
text-align: center;
text-decoration: none;
margin: 0;
padding: 0 25px;
}
.feature-table a: hover h3 {
color: #f6ce4f;
}
.feature-table a {
text-decoration: none;
}
.feature-table p {
font-family: 'GothamLight', sans-serif;
font-size: 14.5px;
color: #949494;
text-align: center;
padding: 10px 28px;
}
.feature-table .caret {
border-top: 5px solid #fff;
border-bottom: 5px solid #fff;
border-left: 5px solid #ffc235;
content: "";
display: inline-block;
height: 0;
width: 0;
margin-left: 10px;
}
This is part of my HTML:
<div id="box">
<a href="#">
<img src="images/payment_icon.png" width="114" height="115" border="0" />
<h3>Customizable Campaign Pages</h3>
<p>Tell your story with images, video, rich text and social updates<b class="caret"></b></p>
</a>
</div>
Any ideas?
It may be a performance issue because you're animating 2 different properties that affect the current layout.
The ideal solution would be to use a certain prop that doesn't affect the other elements. In your case, this can be done with the top property, after setting the image's position to relative :
a img{
position : relative;
top : 0;
}
a:hover img{
top : -4px;
}
Here's a working demo : http://jsfiddle.net/p7Lxz/