Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sticky Bar Can't do the float:right

Tags:

html

css

I've used my bootstrap-3 website for the sticky bar, I try to do like this How TO - Sticky Social Bar and I do some modification,

I used the float: right; but it does not work,

my conflict is , that bar cant set to the web site float:right ,I want to take the right side

anyone know how to do that.

Thanks.

  position: fixed;
  top: 50%;  float: right;

}

.icon-bar a {
  display: block;
  text-align: center;
  padding: 16px;
  transition: all 0.3s ease;
  color: white;
  font-size: 20px;
}

.icon-bar a:hover {
  background-color: #000;
}

.facebook {
  background: #3B5998;
  color: white;
}
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
body {margin:0;height:2000px;}

.icon-bar {
  position: fixed;
  top: 50%;
  -webkit-transform: translateY(-50%);
  -ms-transform: translateY(-50%);
  transform: translateY(-50%);
}

.icon-bar a {
  display: block;
  text-align: center;
  padding: 16px;
  transition: all 0.3s ease;
  color: white;
  font-size: 20px;
}

.icon-bar a:hover {
  background-color: #000;
}

.facebook {
  background: #3B5998;
  color: white;
}

.twitter {
  background: #55ACEE;
  color: white;
}

.google {
  background: #dd4b39;
  color: white;
}

.linkedin {
  background: #007bb5;
  color: white;
}

.youtube {
  background: #bb0000;
  color: white;
}

.content {
  margin-left: 75px;
  font-size: 30px;
}
</style>
<body>


<div class="icon-bar">
  <a href="#" class="facebook">RFQ</a>

</div>


<div class="content">
 </div>

</body>
</html> 
like image 883
core114 Avatar asked Oct 17 '18 04:10

core114


2 Answers

Use right:0; when you give its position - fixed or absolute.

Also - a codepen example https://codepen.io/anon/pen/aRqvqG (the example you mentioned in your question)

.icon-bar a {
  display: block;
  text-align: center;
  padding: 16px;
  transition: all 0.3s ease;
  color: white;
  font-size: 20px;
}

.icon-bar a:hover {
  background-color: #000;
}

.facebook {
  background: #3B5998;
  color: white;
}
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
body {margin:0;height:2000px;}

.icon-bar {
  position: fixed;
  top: 50%;
   right: 0;
  -webkit-transform: translateY(-50%);
  -ms-transform: translateY(-50%);
  transform: translateY(-50%);
}

.icon-bar a {
  display: block;
  text-align: center;
  padding: 16px;
  transition: all 0.3s ease;
  color: white;
  font-size: 20px;
}

.icon-bar a:hover {
  background-color: #000;
}

.facebook {
  background: #3B5998;
  color: white;
}

.twitter {
  background: #55ACEE;
  color: white;
}

.google {
  background: #dd4b39;
  color: white;
}

.linkedin {
  background: #007bb5;
  color: white;
}

.youtube {
  background: #bb0000;
  color: white;
}

.content {
  margin-left: 75px;
  font-size: 30px;
}
</style>
<body>


<div class="icon-bar">
  <a href="#" class="facebook">RFQ</a>

</div>


<div class="content">
 </div>

</body>
</html> 
like image 173
Viira Avatar answered Oct 17 '22 17:10

Viira


Use right:0; instead of float:right because float:right will not work with position:fixed;

like image 24
Vikas Jadhav Avatar answered Oct 17 '22 15:10

Vikas Jadhav