hey guys i am new to css in general , I am having a small problem with positioning a couple of social icons, basicaly , all i want to acheive is the following :
the social icons should be centered.
the social icons should touch the top of the main container div .
the 1st objective i have acheived , but i am having difficulty with the secound . , below is the HTML and CSS code :
HTML ::
<section id="contact-us" class="contact-us">
<div class="overlay">
<div class="social-icons">
<ul>
<li>
<a href="">
<i class="fa fa-twitter"></i>
</a>
</li>
<li>
<a href="">
<i>|</i>
</a>
</li>
<li>
<a href="">
<i class="fa fa-facebook"></i>
</a>
</li>
</ul>
</div>
</div>
</section>
CSS ::
html,body {
height: 100%;
}
.contact-us {
background: url(http://wallpaperswiki.com/wallpapers/2012/12/Abstract-Color-Point-1050x1400.jpg);
height: 100%;
}
.overlay {
height: 100%;
background: rgba(146,39,143,.5);
}
.social-icons {
text-align: center;
}
.social-icons ul {
list-style: none;
padding:0;
margin: 0;
display: inline-block;
}
.social-icons ul li {
margin-left: 5px;
margin-right: 5px;
display: inline-block;
}
.social-icons li a {
color: #fff;
}
.social-icons li a i {
font-size: 2em;
}
FIDDLE HERE
notice how the social icons are not touching the top of the main container. actually , all three elements , the 2 social icons and the line inbetween them should touch the top of the main container.
ON inspection :: i am using bootstap , and bootstap has a line-height of 1.42857 as default , if i make the line-height on social-icons to 0 the socia icons get closer to the top , NEARLY SOLVES MY PROBLEM . but still not all three icons are touching the top ? WHY ? and how do i solve this problem ?
EDIT ::
The output i want is the following :
Thank you.
Alex-z.
Related
This question already has an answer here:
Why does clip-path (and other properties) affect the stacking order (z-index) of elements later in DOM?
(1 answer)
Closed 2 years ago.
I made my navigation bar and positioned it (fixed), and it works fine. I was able to scroll down and all. As soon has I added filter (brightness) to it the image on my page, the navigation bar disappeared. I have tried using pseudo-elements and setting the position (absolute/relative), I set the filter property to the container of the child element of the image, it still didn't work. Can someone help me on how to have my navigation bar display on fixed position and still have the image filtered. Thanks in Advance.
nav {
position: fixed;
background-color: #fff;
}
nav ul {
margin: 0;
padding: 0;
}
.navbar-brand {
padding-right: 20px;
}
nav li {
display: inline-block;
padding: 10px;
}
nav a {
color: #000;
text-decoration: none;
}
nav a:hover {
color: #ff6600;
text-decoration: none;
}
.title-image img {
width: 100%;
height: 300px;
filter: brightness(60%);
}
<nav>
<ul>
<li>
<a class="navbar-brand" href="#">Navbar Brand</a>
</li>
<li>
Home
</li>
<li>
About
</li>
<li>
services
</li>
</ul>
</nav>
<div class="title-image">
<img src="https://images.unsplash.com/photo-1599546824091-f49550ce8cbc?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60">
</div>
JSfiddle Demo
Just add z-index to your nav element as follow
nav{
position: fixed;
background-color: #fff;
z-index:999;
}
nav ul{
margin: 0;
padding: 0;
}
.navbar-brand{
padding-right: 20px;
}
nav li{
display: inline-block;
padding: 10px;
}
nav a{
color: #000;
text-decoration: none;
}
nav a:hover{
color: #ff6600;
text-decoration: none;
}
.title-image img{
width: 100%;
height: 300px;
filter: brightness(60%);
}
<nav>
<ul>
<li>
<a class="navbar-brand" href="#">Navbar Brand</a>
</li>
<li>
Home
</li>
<li>
About
</li>
<li>
services
</li>
</ul>
</nav>
<div class="title-image">
<img src="https://images.unsplash.com/photo-1599546824091-f49550ce8cbc?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60">
</div>
The navbar didn't disappear, it is just beneath the image. To have it in front, you should use z-index: 10; (or any value greater than 0).
See more at : https://developer.mozilla.org/en-US/docs/Web/CSS/z-index
In addition, keep in mind that your image - or any element after your navbar - will be positioned on top of your page. May be you'll want to let the equivalent of the navbar height as space before any content.
This is normally a question I don't need answered, however, I am baffled. I have tried everything I can think of.
This picture includes a gray piece at the right. That is the scroll bar, figured I would include it. This is on Google Chrome and how I want it.
And this is how Microsoft Edge does it.
I narrowed the problem down to my list items <li>. On Google Chrome (according to my resolutions), the width of <li> is 226.141px and on Microsoft Edge, using the same exact CSS, the width of <li> is 226.35px.
Here is my style.css:
div.menuContainer {
width:100%;
height:48px;
}
ul.menuItems {
/*margin:-12px;*/
}
li.menuItem {
display:inline-block;
box-sizing:border-box;
width:calc(100% / 7);
float:left;
text-align:center;
height:48px;
font-weight:bold;
background-color:#DD4400;
color:#454545;
padding:12px 0;
overflow:hidden !important;
}
li.menuItem:hover {
background-color:#454545;
color:#DD4400;
}
li.menuItem a {
color:#454545;
}
li.menuItem a:hover {
color:#DD4400;
}
Here is my menu:
<div class="menuContainer">
<ul class="menuItems">
<a href="/videos.php">
<li class="menuItem">
Videos
</li>
</a>
<a href="/playlists.php">
<li class="menuItem">
Playlists
</li>
</a>
<a href="/categories.php">
<li class="menuItem">
Categories
</li>
</a>
<a href="/actors.php">
<li class="menuItem">
Actors
</li>
</a>
<a href="/photos.php">
<li class="menuItem">
Photos
</li>
</a>
<?php if($logged_in == 0) { ?>
<a href="/login.php">
<li class="menuItem">
Login
</li>
</a>
<a href="/register.php">
<li class="menuItem">
Register
</li>
</a>
<?php }
else { ?>
<a href="/logout.php">
<li class="menuItem">
Logout
</li>
</a>
<a href="/account.php">
<li class="menuItem">
My Account
</li>
</a>
<?php }
?>
</ul>
</div>
Any help you can provide would be greatly appreciated. Thank You.
Here's a different way of approaching the same problem using flexbox. I also made some slight modifications to your HTML. The key to this approach is using display: flex on the container and flex-grow: 1 on the children of that container. Note: I also use display: flex to achieve vertical and horizontal centering on the <a> elements, rather than having to use top and bottom padding.
.menu {
height: 48px;
display: flex;
}
.menu a {
flex-grow: 1;
display: flex;
font-weight: bold;
background-color: #DD4400;
color: #454545;
align-items: center;
justify-content: center;
text-decoration: none;
}
.menu a:hover {
text-decoration: underline;
}
<div class="menu">
Videos
Playlists
Categories
Actors
Photos
Logout
My Account
</div>
Here's a quick article explaining what flexbox can do for you - css-tricks.com/snippets/css/a-guide-to-flexbox. I'd highly recommend adding this to your toolkit - it's relatively modern, but has very good browser support caniuse.com/#feat=flexbox. I use it very regularly.
Do a reset in your css, as a first thing:
* {
/* So 100% means 100% */
box-sizing: border-box;
}
See link for details.
Can someone help me understand how can I vertical align this?
JSFIDDLE
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/MaterialDesign-Webfont/2.0.46/css/materialdesignicons.css"
></link>
<aside class="menu column is-2 full-height">
<ul class="menu-list">
<li>
<a href="#" class="">
<i class="mdi mdi-file-document-box mdi-48px"></i>
<span>Document</span>
</a>
</li>
<li>
<a href="#" class="">
<i class="mdi mdi-file-document-box mdi-48px"></i>
<span>Document</span>
</a>
</li>
</ul>
</aside>
I need align icon and text next to it?
there is some more css since I'm using bulma.io and something custom but not so relevant I think
You can delete that css and create new one if it is not ok
There's a few options at your disposal, depending on your needs.
Updated jsFiddle
Use display: inline-block; on the element(s) that are next to each other and need to be aligned. Then you can use vertical-align: [top|middle|baseline] as needed for each element
i, span {
display: inline-block;
vertical-align: middle;
}
If that alignment doesn't work for you, then you should set the vertical-align to top, to get them positioned how you like, and then you can use line-height to fine-tune the vertical positioning of each element. Example:
i, span {
display: inline-block;
vertical-align: top;
}
i {
line-height: 39px;
}
span {
line-height: 39px;
}
You can add display: flex and align-items: center rules to li a
fiddle
aside {
background-color: #0067ad;
height: 100%;
}
li a {
display: flex;
align-items: center;
}
.menu-list {
list-style: none;
}
i {
color: white;
}
a:hover,
a:active,
.router-link-active {
background-color: black;
}
span {
color: white;
}
}
a {
color: white
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/MaterialDesign-Webfont/2.0.46/css/materialdesignicons.css" rel="stylesheet"/>
<aside class="menu column is-2 full-height">
<ul class="menu-list">
<li>
<a href="#" class="">
<i class="mdi mdi-file-document-box mdi-48px"></i>
<span>Document</span>
</a>
</li>
<li>
<a href="#" class="">
<i class="mdi mdi-file-document-box mdi-48px"></i>
<span>Document</span>
</a>
</li>
</ul>
</aside>
I've been having this issue in different places where I have a ul list and Im trying to add it on top of a div (image, or a background) but the list does not appear on top. I wonder if it gets sent in the back..i even added z-index
JSFiddle
CSS
.toolbar p{ text-align: right; padding: 10px 180px 0 0; color: #fff; font-size: 26px; z-index: 1; }
.toolbar { width: auto; height: 50px; background-color: #cc1e2c; z-index: 1;}
.social-icons { z-index: 2;}
HTML
<div class="col_full toolbar">
<p>CALL NOW: +1 555.555.1234</p>
<ul class="social-icons">
<li> </li>
<li> </li>
<li> </li>
</ul>
</div>
The reason you aren't seeing anything is because you posted links, without any content. If you added words, the list would appear:
<div class="col_full toolbar">
<p>CALL NOW: +1 555.555.1234</p>
<ul class="social-icons">
<li> Twitter </li>
<li> Instagram</li>
<li> Facebook</li>
</ul>
</div>
On this example I made the height bigger so you could see that the links are in fact on top.
If you want to see the images, you need to use the image tag like so:
<li> <img src="path/to/your/twitter_image.jpg"/> </li>
JSFiddle
I am trying to get my 5 Font Awesome Icons over my background image with a fixed position. That fixed position should allow me to scroll past it whitout any problem. I know that there is a way but i am not finding it.
My HTML:
<!--Kaffe abschnitt -->
<!--5 Icons-->
<ul>
<li><i class="fa fa-cog fa-5x"></i></li>
<li><i class="fa fa-rebel fa-5x"></i></li>
<li><i class="fa fa-empire fa-5x"></i></li>
<li><i class="fa fa-twitch fa-5x"></i> </li>
<li><i class="fa fa-steam fa-5x"></i> </li>
</ul>
<!--Ende 5 Icons-->
<!--Hintergrund-->
<img src="img/bild2.png" class="container-full">
<!--Ende Kaffe abschnitt -->
Background CSS:
.container-full {
margin: 0 auto;
width: 100%;
z-index: -999;
}
Icon CSS:
ul li {
list-style-type: none;
float: left;
}
ul li a span {
background: transparent;
color: #205D7A;
width: 240px;
height: 240px;
border-radius: 50%;
border: 2px solid;
text-align: center;
transition: all 0.2s ease-in-out;
z-index: 998;
}
ul li a span:hover {
opacity: .8;
}
I am not asking for a premade full code. Just the name of the actions or some short code snipeds.
I am trying to get my 5 Font Awesome Icons over my background image with a fixed position.
You don't want to use 'position:fixed' if you want to scroll past them.
Instead, use position:absolute.
absolute will position elements according to the first parent that has anything but "position:static", i suggest setting "position:relative" on the parent you want your elements to position them self according to.
If you want your "icons" to be along the right hand side of a div, then it would have looked like this
#myDiv{position:relative;} //the container
.myIcons{position:absolute; right:0} //a handy class on all your icons spans/i
.icon1{top:0px} //these are just unique classes per icon
.icon2{top:20px}
.icon3{top:40px}
Hope this gets you in the righth direction