The background color is not appearing, I want to set the social media icons with some background color which covers the whole webpage width and a specific height.
<div class = "social-media">
<div class="middle">
<a class="btn" href="#">
<i class="fab fa-facebook-f"></i>
</a>
<a class="btn" href="#">
<i class="fab fa-instagram"></i>
</a>
<a class="btn" href="#">
<i class="fab fa-linkedin-in"></i>
</a>
<a class="btn" href="#">
<i class="fab fa-twitter"></i>
</a>
</div>
</>
CSS:
.social-media{
background-color: black;
position: absolute;
height: 10%;
}
Set the left:0 and right:0 position.
.social-media{
background-color: black;
position: absolute;
height: 10%;
left: 0;
right: 0;
}
You should specify width and height too.
Set width to CSS Class
.social-media{
background-color: black;
position: absolute;
height: 10%;
width:10%;
}
Related
I am trying to make a social media menu, the Font Awesome Icons are all visible and the way I want but the hyperlink is not working on it.....
Here is my code:
.sm-list {
display: flex;
}
.sm-link {
color: #929FC5;
width: 3rem;
height: 3rem;
border: 1px solid #929FC5;
border-radius: 90%;
display: flex;
align-items: center;
justify-content: center;
margin-right: 0.5rem;
}
.sm-link:last-child {
margin-right: 0;
}
.sm-link:hover {
background-image: linear-gradient(to right, #A971FF, #00F0FF);
color: #FFF;
}
<div class="sm-list">
<a href="https://www.facebook.com/" class="sm-link">
<i class="fab fa-facebook"></i>
</a>
<a href="https://www.instagram.com/" class="sm-link">
<i class="fab fa-instagram"></i>
</a>
<a href="https://www.twitter.com/" class="sm-link">
<i class="fab fa-twitter"></i>
</a>
<a href="https://www.youtube.com/" class="sm-link">
<i class="fab fa-youtube"></i>
</a>
</div>
I was able to load the icons with the following code. You must first load the Font Awesome in the head tag
<head>
<link rel="stylesheet" href="mystyle.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" rel="stylesheet">
</head>
<body>
<div class="sm-list">
<a href="https://www.facebook.com/" class="sm-link">
<i class="fab fa-facebook"></i>
</a>
<a href="https://www.instagram.com/" class="sm-link">
<i class="fab fa-instagram"></i>
</a>
<a href="https://www.twitter.com/" class="sm-link">
<i class="fab fa-twitter"></i>
</a>
<a href="https://www.youtube.com/" class="sm-link">
<i class="fab fa-youtube"></i>
</a>
</div>
</body>
I have this list of icons (fonts) lined up on the bottom of a section's page. On mobile, the line of icons overflows over on the right of that page. I would like to have 3 or 4 icons per row instead on smaller screen. I have tried multiple possibilities and the best I got was the line to be cut off (not having all icons show). Any cue would be greatly appreciated, I don't know what I'm doing wrong :-/
HTML:
<!--Skills-->
<div class="container">
<div class="icons text-center">
<ul>
<li><i class="fab fa-html5"></i></li>
<li><i class="fab fa-css3-alt"></i></li>
<li><i class="fab fa-js"></i></li>
<li><i class="fab fa-bootstrap"></i></li>
<li><i class="fab fa-sass"></i></li>
<li><i class="fab fa-less"></i></li>
<li><i class="fab fa-github"></i></li>
<li><i class="fab fa-wordpress"></i></li>
<li><i class="fab fa-adobe"></i></li>
<li><i class="fab fa-python"></i></li>
</ul>
</div>
</div>
As for CSS:
/*Skills*/
.icons {
padding: 0px 0px;
}
ul {
padding: 0;
margin: 0;
display: flex;
justify-content:space-around;
width: 700px;
margin-left: auto;
margin-right: auto;
}
ul li {
list-style: none;
font-size: 30px;
border-radius: 400px;
width: 50px;
height: 50px;
display: block;
text-align: center;
padding-top: 4px;
padding-bottom: 0px;
color: #2c3e50;
}
.icons > ul li {
flex: 1;
}
form ul li {
font-size: 15px;
width: inherit;
color: #ff0000;
text-align: left;
}
form ul {
margin-left: 0px;
margin-right: 0px;
height: 10px;
}
/*What I tried so far... some of them might be nonesense but I was desperate!*/
#media (max-width: 450px) {
.icons {
padding: 25px;
width: 25%;
flex-wrap: wrap;
position: absolute;
margin:auto;
justify-content: center;
align-items: center;
display:inline-block;
text-align: center;
overflow-x: hidden;
line-height: 1.2;
width: 100%;
margin-bottom: auto;
margin-left: auto;
margin-right: auto;
}
#media (max-width: 450px) {
.icons li {
width: 50%;
}
restructure your code to remove ul, li and let the default behavior manage this for;
working snippet below:
i {
list-style: none;
font-size: 30px;
border-radius: 400px;
width: 50px;
height: 50px;
display: block;
text-align: center;
padding-top: 4px;
padding-bottom: 0px;
color: #2c3e50;
}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.6/css/all.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
Do you really need ul, li ?
<hr/>
<div class="icons text-center">
<i class="fab fa-html5"></i>
<i class="fab fa-css3-alt"></i>
<i class="fab fa-js"></i>
<i class="fab fa-bootstrap"></i>
<i class="fab fa-sass"></i>
<i class="fab fa-less"></i>
<i class="fab fa-github"></i>
<i class="fab fa-wordpress"></i>
<i class="fab fa-adobe"></i>
<i class="fab fa-python"></i>
</div>
You could have done something this way
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<div class="container text-center">
<span style="padding:5px">
<i class="fab fa-facebook-f"></i>
</span>
<span style="padding:5px">
<i class="fab fa-twitter"></i>
</span>
<span style="padding:5px">
<i class="fab fa-html5"></i>
</span> <span style="padding:5px">
<i class="fab fa-html5"></i>
</span> <span style="padding:5px">
<i class="fab fa-html5"></i>
</span> <span style="padding:5px">
<i class="fab fa-html5"></i>
</span> <span style="padding:5px">
<i class="fab fa-html5"></i>
</span> <span style="padding:5px">
<i class="fab fa-html5"></i>
</span> <span style="padding:5px">
<i class="fab fa-html5"></i>
</span>
<span style="padding:5px">
<i class="fab fa-facebook-f"></i>
</span>
<span style="padding:5px">
<i class="fab fa-twitter"></i>
</span> <span style="padding:5px">
<i class="fab fa-facebook-f"></i>
</span>
<span style="padding:5px">
<i class="fab fa-twitter"></i>
</span> <span style="padding:5px">
<i class="fab fa-facebook-f"></i>
</span>
<span style="padding:5px">
<i class="fab fa-twitter"></i>
</span>
</div>
Hi I want to know that whether can i reduce length of border bottom. I have a div and i have given border-bottom: 2px to that div i want to reduce the length of border. Is this possible.
I have this nav-bar and i have given css to its div want to reduce length of border. How can i do that.
This is my html
<div class="row">
<div class="col-sm-12 col-xs-12 col-lg-12 col-md-12 welcome">
<ul class="nav navbar-nav navbar-nav-primary">
<li class="active">
<a href="#one" data-toggle="tab">
<i class="fa fa-map-marker" aria-hidden="true"></i> <span class="li-text">Location</span>
</a>
</li>
<li>
<a href="#two" data-toggle="tab">
<i class="fa fa-heartbeat" aria-hidden="true"></i> <span class="li-text">Heartbeats</span>
</a>
</li>
<li>
<a href="#three" data-toggle="tab">
<i class="fa fa-power-off" aria-hidden="true"></i>
<span class="li-text">Reboots</span>
</a>
</li>
<li>
<a href="#four" data-toggle="tab">
<i class="fa fa-compress" aria-hidden="true"></i>
<span class="li-text">Reconnects</span>
</a>
</li>
<li>
<a href="#five" data-toggle="tab">
<i class="fa fa-battery-full" aria-hidden="true"></i>
<span class="li-text">Charge</span>
</a>
</li>
</ul>
</div>
This is my CSS
.welcome {
border-bottom: 2px solid #bcbcbc;
margin-left: 10px;
}
Move the welcome class into the ul tag and it should do what you want :)
remove the border-bottom css from the class welcome
and use this;
ul.nav.navbar-nav.navbar-nav-primary {
border-bottom: 2px solid #ddd;
}
.welcome {
margin-left: 10px;
}
You can use this for set height and width for set length
.welcome{
width:1000px;
border-bottom:1px solid magenta;
height:100px;
}
I was try to set icons and text on images but it put extra space beside image, so how can i remove extra space from image?
.fb {
position: absolute;
top: 0px;
right: 5px;
z-index: 100;
}
.tweeter {
position: absolute;
top: 20px;
right: 5px;
z-index: 100;
}
img {
overflow: hidden;
}
div {
height: 250px;
width: 250px;
display: inline;
}
<div>
<img https://pbs.twimg.com/profile_images/604644048/sign051.gif">
<a class="fb" href=""><i class="fa fa-facebook-official" aria-hidden="true"></i></a>
<a class="tweeter" href=""><i class="fa fa-twitter-square" aria-hidden="true"></i></a>
</div>
<div>
<img https://pbs.twimg.com/profile_images/604644048/sign051.gif">
<a class="fb" href=""><i class="fa fa-facebook-official" aria-hidden="true"></i></a>
<a class="tweeter" href=""><i class="fa fa-twitter-square" aria-hidden="true"></i></a>
</div>
<div>
<img https://pbs.twimg.com/profile_images/604644048/sign051.gif">
<a class="fb" href=""><i class="fa fa-facebook-official" aria-hidden="true"></i></a>
<a class="tweeter" href=""><i class="fa fa-twitter-square" aria-hidden="true"></i></a>
</div>
<div>
<img https://pbs.twimg.com/profile_images/604644048/sign051.gif">
<a class="fb" href=""><i class="fa fa-facebook-official" aria-hidden="true"></i></a>
<a class="tweeter" href=""><i class="fa fa-twitter-square" aria-hidden="true"></i></a>
</div>
first : your img tags are not correct. should be <img src="url">
second : display:inline generates white spaces between elements. so i suggest you use float:left instead
for example if you want 4 divs on one row, use float:left;width:25%; that way you are sure there are no white spaces between the divs
also to be sure the img covers all the width of the div, use width:100%;height:auto on the img. plus overflow:hidden on the img has no effect . you can use it on the div instead
see snippet below :
.fb {
position: absolute;
top: 0px;
right: 5px;
z-index: 100;
}
.tweeter {
position: absolute;
top: 20px;
right: 5px;
z-index: 100;
}
img {
width:100%;
height:auto;
}
div {
height: 250px;
width: 250px;
float:left;
width:25%;
position:relative;
}
<link href="https://netdna.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet"/>
<div>
<img src="https://pbs.twimg.com/profile_images/604644048/sign051.gif">
<a class="fb" href=""><i class="fa fa-facebook-official" aria-hidden="true"></i></a>
<a class="tweeter" href=""><i class="fa fa-twitter-square" aria-hidden="true"></i></a>
</div>
<div>
<img src ="https://pbs.twimg.com/profile_images/604644048/sign051.gif">
<a class="fb" href=""><i class="fa fa-facebook-official" aria-hidden="true"></i></a>
<a class="tweeter" href=""><i class="fa fa-twitter-square" aria-hidden="true"></i></a>
</div>
<div>
<img src ="https://pbs.twimg.com/profile_images/604644048/sign051.gif">
<a class="fb" href=""><i class="fa fa-facebook-official" aria-hidden="true"></i></a>
<a class="tweeter" href=""><i class="fa fa-twitter-square" aria-hidden="true"></i></a>
</div>
<div>
<img src ="https://pbs.twimg.com/profile_images/604644048/sign051.gif">
<a class="fb" href=""><i class="fa fa-facebook-official" aria-hidden="true"></i></a>
<a class="tweeter" href=""><i class="fa fa-twitter-square" aria-hidden="true"></i></a>
</div>
I need these buttons to be horizontally centered within their container..as you can see, they are floating to the left. That is because I have a float: left; attribute on them.
However, when I remove the float: left; attribute and apply text-align: center; to the container, this is what happens...
Almost centered, but not quite. What's the deal? Thanks! :)
The container's CSS:
#navbar {
background: #303030;
width: 100%;
box-sizing: border-box;
text-align: center;
}
Each button's CSS:
a.button {
width: 16.3%;
background: #4d4d4d;
height: 50px;
display: inline-block;
text-decoration: none;
color: #fff;
text-align: center;
max-width: 250px;
padding-top: 12px;
box-sizing: border-box;
font-size: 145%;
transition-property: background, z-index, font-size, color;
transition-duration: 0.35s;
}
The relevant HTML
<div id ="navbar">
<i class="fa fa-home"></i> HOME
<i class="fa fa-question"></i> Q&A
<i class="fa fa-comment"></i> FORUMS
<i class="fa fa-phone"></i> CONTACT
<i class="fa fa-life-ring"></i> SUPPORT
<i class="fa fa-info-circle"></i> ABOUT
</div>
</div>
The misalignment is probably due to a space character between each link. This is a common problem when using display: inline-block;. You can remove with a couple of methods.
Method 1:
Set a negative letter-spacing. This depends on font-family and font-size, so try a couple of different values.
#navbar {
letter-spacing: -4px;
}
a.button {
letter-spacing: normal;
}
Method 2:
Remove any space/linebreaks between the links. This will of course make the code pretty unreadable.
<i class="fa fa-home"></i> HOME<i class="fa fa-question"></i> Q&A<i class="fa fa-comment"></i> FORUMS<i class="fa fa-phone"></i> CONTACT<i class="fa fa-life-ring"></i> SUPPORT<i class="fa fa-info-circle"></i> ABOUT
Method 3:
Ommit the closing </a> for all links but the last. This is still valid HTML. An <a> element will automatically close when it's followed by another <a>.
<a href="https://www.answers.legal" class="button"><i class="fa fa-home"></i> HOME
<a href="https://www.answers.legal/questions" class="button"><i class="fa fa-question"></i> Q&A
<a href="https://www.answers.legal/forums" class="button"><i class="fa fa-comment"></i> FORUMS
<a href="https://www.answers.legal/contact" class="button"><i class="fa fa-phone"></i> CONTACT
<a href="https://www.answers.legal/support" class="button"><i class="fa fa-life-ring"></i> SUPPORT
<i class="fa fa-info-circle"></i> ABOUT