Bootstrap Footer: Trouble Centering The Social Media Icons - html

I have been trying to center the Social media Icons for over an hour and I seem to go nowhere.
Below is the HTML code snippet.
<footer>
<div class="container">
<div class="row-footer">
<div class="row row-content">
<div class="nav navbar-nav" style="padding: 40px 10px;">
<a class="btn btn-social-icon btn-google-plus" href="http://google.com/+"><i class="fa fa-google-plus"></i></a>
<a class="btn btn-social-icon btn-facebook" href="http://www.facebook.com/profile.php?id="><i class="fa fa-facebook"></i></a>
<a class="btn btn-social-icon btn-linkedin" href="http://www.linkedin.com/in/"><i class="fa fa-linkedin"></i></a>
<a class="btn btn-social-icon btn-twitter" href="http://twitter.com/"><i class="fa fa-twitter"></i></a>
<a class="btn btn-social-icon btn-youtube" href="http://youtube.com/"><i class="fa fa-youtube"></i></a>
<a class="btn btn-social-icon" href="mailto:"><i class="fa fa-envelope-o"></i></a>
</div>
</div>
</div>
</div>
</footer>
And below is the CSS code snippet.
.row-footer {
background-color: #AfAfAf;
margin:200px auto;
padding: 20px 0px 20px 0px;
}
.navbar-nav {
display: inline-block;
text-align: center;
}
This is how its appearing on Google Chrome.

Because you're using the navbar-nav class you have to remove it's default float:left rule.
.navbar-nav {
padding: 40px 10px;
float: none;
text-align: center;
}
Working Example 1:
.row-footer {
background-color: #AfAfAf;
margin: 200px auto;
padding: 20px 0px 20px 0px;
}
div.navbar-nav {
padding: 40px 10px;
float: none;
text-align: center;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<footer>
<div class="container">
<div class="row-footer">
<div class="row">
<div class="nav navbar-nav">
<a class="btn btn-social-icon btn-google-plus" href="http://google.com/+"><i class="fa fa-google-plus"></i></a>
<a class="btn btn-social-icon btn-facebook" href="http://www.facebook.com/profile.php?id="><i class="fa fa-facebook"></i></a>
<a class="btn btn-social-icon btn-linkedin" href="http://www.linkedin.com/in/"><i class="fa fa-linkedin"></i></a>
<a class="btn btn-social-icon btn-twitter" href="http://twitter.com/"><i class="fa fa-twitter"></i></a>
<a class="btn btn-social-icon btn-youtube" href="http://youtube.com/"><i class="fa fa-youtube"></i></a>
<a class="btn btn-social-icon" href="mailto:"><i class="fa fa-envelope-o"></i></a>
</div>
</div>
</div>
</div>
</footer>
Working Example 2:
.row-footer {
background-color: #AfAfAf;
margin: 200px 0;
}
.footer-nav {
text-align: center;
padding: 40px 0;
}
.footer-nav a {
display: inline-block;
padding: 0 20px;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<footer>
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="row-footer">
<div class="footer-nav">
<a class="btn btn-social-icon btn-google-plus" href="#">
<i class="fa fa-google-plus"></i>
</a>
<a class="btn btn-social-icon btn-facebook" href="#">
<i class="fa fa-facebook"></i>
</a>
<a class="btn btn-social-icon btn-linkedin" href="#">
<i class="fa fa-linkedin"></i>
</a>
<a class="btn btn-social-icon btn-twitter" href="#">
<i class="fa fa-twitter"></i>
</a>
<a class="btn btn-social-icon btn-youtube" href="#">
<i class="fa fa-youtube"></i>
</a>
<a class="btn btn-social-icon" href="#">
<i class="fa fa-envelope-o"></i>
</a>
</div>
</div>
</div>
</div>
</div>
</footer>

Try using display: inline-block; on the icon combined with text-align:center on icons container.
If there is going to be more children than just the icons, consider wrapping them into another <div>.
a {
display: inline-block;
}
.navbar-nav {
text-align: center;
}
Here is updated jsfiddle

Related

Links not working in Font Awesome Social media Icon Menu

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>

HTML popup menu prevent overflow container

I have following code which show popupmenu when click on icon on each block, right now for the third block the menu overflow the black container, I need to display inside the container by shifting the menu div towards left side. Only the last column menu need to shift left for keeping the position inside the container.
How it's possible?
function myFunction(id) {
document.getElementById(id).classList.toggle("show");
}
window.onclick = function(event) {
if (!event.target.matches('.dropbtn')) {
var dropdowns = document.getElementsByClassName("edit-dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}
.grid_container {
display: grid;
grid-template-columns: repeat(auto-fill, 150px);
grid-gap: 10px;
justify-content: center;
align-content: flex-start;
margin: 0 auto;
margin-top: 0px;
text-align: center;
margin-top: 10px;
width: 508px;
background: black;
}
.grid_block {
background-color: #269ad3 !important;
color: #efefef;
border: 1px solid #ccc;
width: 150px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}
.edit-dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 120px;
overflow: auto;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.edit-dropdown-content a {
color: black;
padding: 5px 12px 5px 16px;
text-decoration: none;
display: block;
text-align: left;
font-size: 14px;
}
.w3-right {
float: right !important;
padding: 10px;
}
.w3-xlarge {
font-size: 25px;
}
.show {
display: block;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div id="pdf_parent_id" class="grid_container">
<div class="grid_block">
<div>
<h5>Title</h5>
<i class="fa fa-file-pdf-o"></i>
<h6 style="font-size:12px;">Subtitle</h6>
<div class="w3-right">
<i onclick="myFunction('dropdown_menu0')" class="dropbtn fa fa-ellipsis-v w3-xlarge"></i>
<div id="dropdown_menu0" class="edit-dropdown-content">
<a class="contextMenu"><i class="fa fa-edit"></i> Menu1</a>
<a class="contextMenu"><i class="fa fa-download"></i> Menu2</a>
<a class="contextMenu"><i class="fa fa-share"></i> Menu3</a>
<a class="contextMenu"><i class="fa fa-trash"></i> Menu4</a></div>
</div>
</div>
</div>
<div class="grid_block">
<div>
<h5>Title</h5>
<i class="fa fa-file-pdf-o"></i>
<h6 style="font-size:12px;">Subtitle</h6>
<div class="w3-right">
<i onclick="myFunction('dropdown_menu1')" class="dropbtn fa fa-ellipsis-v w3-xlarge"></i>
<div id="dropdown_menu1" class="edit-dropdown-content">
<a class="contextMenu"><i class="fa fa-edit"></i> Menu1</a>
<a class="contextMenu"><i class="fa fa-download"></i> Menu2</a>
<a class="contextMenu"><i class="fa fa-share"></i> Menu3</a>
<a class="contextMenu"><i class="fa fa-trash"></i> Menu4</a></div>
</div>
</div>
</div>
<div class="grid_block">
<div>
<h5>Title</h5>
<i class="fa fa-file-pdf-o"></i>
<h6 style="font-size:12px;">Subtitle</h6>
<div class="w3-right">
<i onclick="myFunction('dropdown_menu2')" class="dropbtn fa fa-ellipsis-v w3-xlarge"></i>
<div id="dropdown_menu2" class="edit-dropdown-content">
<a class="contextMenu"><i class="fa fa-edit"></i> Menu1</a>
<a class="contextMenu"><i class="fa fa-download"></i> Menu2</a>
<a class="contextMenu"><i class="fa fa-share"></i> Menu3</a>
<a class="contextMenu"><i class="fa fa-trash"></i> Menu4</a></div>
</div>
</div>
</div>
<div class="grid_block">
<div>
<h5>Title</h5>
<i class="fa fa-file-pdf-o"></i>
<h6 style="font-size:12px;">Subtitle</h6>
<div class="w3-right">
<i onclick="myFunction('dropdown_menu3')" class="dropbtn fa fa-ellipsis-v w3-xlarge"></i>
<div id="dropdown_menu3" class="edit-dropdown-content">
<a class="contextMenu"><i class="fa fa-edit"></i> Menu1</a>
<a class="contextMenu"><i class="fa fa-download"></i> Menu2</a>
<a class="contextMenu"><i class="fa fa-share"></i> Menu3</a>
<a class="contextMenu"><i class="fa fa-trash"></i> Menu4</a></div>
</div>
</div>
</div>
Here is the fiddle
https://jsfiddle.net/kvzbuLn9/
Possibly you can do this:
.w3-right {
position: relative;
}
#dropdown_menu3 {
bottom: 30px;
position: absolute;
}
EDIT: Use this code:
#dropdown_menu2{
position: absolute;
right: 10px;
}
Working example:
function myFunction(id) {
document.getElementById(id).classList.toggle("show");
}
window.onclick = function(event) {
if (!event.target.matches('.dropbtn')) {
var dropdowns = document.getElementsByClassName("edit-dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}
.grid_container {
display: grid;
grid-template-columns: repeat(auto-fill, 150px);
grid-gap: 10px;
justify-content: center;
align-content: flex-start;
margin: 0 auto;
margin-top: 0px;
text-align: center;
margin-top: 10px;
width:508px;
background:black;
}
.grid_block {
background-color: #269ad3 !important;
color: #efefef;
border: 1px solid #ccc;
width: 150px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}
.edit-dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 120px;
overflow: auto;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.edit-dropdown-content a {
color: black;
padding: 5px 12px 5px 16px;
text-decoration: none;
display: block;
text-align: left;
font-size: 14px;
}
.w3-right {
float: right !important;
padding:10px;
}
.w3-xlarge{
font-size:25px;
}
.show {display: block;}
.w3-right {
position: relative;
}
#dropdown_menu3 {
bottom: 30px;
position: absolute;
}
#dropdown_menu2{
position: absolute;
right: 10px;
}
<!DOCTYPE html>
<head>
<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">
</head>
<body>
<div id="pdf_parent_id" class="grid_container">
<div class="grid_block">
<div>
<h5>Title</h5>
<i class="fa fa-file-pdf-o"></i>
<h6 style="font-size:12px;">Subtitle</h6>
<div class="w3-right">
<i onclick="myFunction('dropdown_menu0')" class="dropbtn fa fa-ellipsis-v w3-xlarge"></i>
<div id="dropdown_menu0" class="edit-dropdown-content">
<a class="contextMenu"><i class="fa fa-edit"></i> Menu1</a>
<a class="contextMenu"><i class="fa fa-download"></i> Menu2</a>
<a class="contextMenu"><i class="fa fa-share"></i> Menu3</a>
<a class="contextMenu"><i class="fa fa-trash"></i> Menu4</a></div>
</div>
</div>
</div>
<div class="grid_block">
<div>
<h5>Title</h5>
<i class="fa fa-file-pdf-o"></i>
<h6 style="font-size:12px;">Subtitle</h6>
<div class="w3-right">
<i onclick="myFunction('dropdown_menu1')" class="dropbtn fa fa-ellipsis-v w3-xlarge"></i>
<div id="dropdown_menu1" class="edit-dropdown-content">
<a class="contextMenu"><i class="fa fa-edit"></i> Menu1</a>
<a class="contextMenu"><i class="fa fa-download"></i> Menu2</a>
<a class="contextMenu"><i class="fa fa-share"></i> Menu3</a>
<a class="contextMenu"><i class="fa fa-trash"></i> Menu4</a></div>
</div>
</div>
</div>
<div class="grid_block">
<div>
<h5>Title</h5>
<i class="fa fa-file-pdf-o"></i>
<h6 style="font-size:12px;">Subtitle</h6>
<div class="w3-right">
<i onclick="myFunction('dropdown_menu2')" class="dropbtn fa fa-ellipsis-v w3-xlarge"></i>
<div id="dropdown_menu2" class="edit-dropdown-content">
<a class="contextMenu"><i class="fa fa-edit"></i> Menu1</a>
<a class="contextMenu"><i class="fa fa-download"></i> Menu2</a>
<a class="contextMenu"><i class="fa fa-share"></i> Menu3</a>
<a class="contextMenu"><i class="fa fa-trash"></i> Menu4</a></div>
</div>
</div>
</div>
<div class="grid_block">
<div>
<h5>Title</h5>
<i class="fa fa-file-pdf-o"></i>
<h6 style="font-size:12px;">Subtitle</h6>
<div class="w3-right">
<i onclick="myFunction('dropdown_menu3')" class="dropbtn fa fa-ellipsis-v w3-xlarge"></i>
<div id="dropdown_menu3" class="edit-dropdown-content">
<a class="contextMenu"><i class="fa fa-edit"></i> Menu1</a>
<a class="contextMenu"><i class="fa fa-download"></i> Menu2</a>
<a class="contextMenu"><i class="fa fa-share"></i> Menu3</a>
<a class="contextMenu"><i class="fa fa-trash"></i> Menu4</a></div>
</div>
</div>
</div>
If your html is static and is not generated by some js code then you can use a straightforward approach - just add additional class to your menu container:
css:
.menu-icon-container {
position: relative;
}
.edit-dropdown-content--inside {
right: 23px;
top: 0;
}
html:
<div class="w3-right menu-icon-container">
<i onclick="myFunction('dropdown_menu2')" class="dropbtn fa fa-ellipsis-v w3-xlarge"></i>
<div id="dropdown_menu2" class="edit-dropdown-content edit-dropdown-content--inside">
<a class="contextMenu"><i class="fa fa-edit"></i> Menu1</a>
<a class="contextMenu"><i class="fa fa-download"></i> Menu2</a>
<a class="contextMenu"><i class="fa fa-share"></i> Menu3</a>
<a class="contextMenu"><i class="fa fa-trash"></i> Menu4</a>
</div>
</div>
You can add position: relative on the .grid-block so we can then add left: 30px on our dropdown. This should position them all to the left.
function myFunction(id) {
document.getElementById(id).classList.toggle("show");
}
window.onclick = function(event) {
if (!event.target.matches('.dropbtn')) {
var dropdowns = document.getElementsByClassName("edit-dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}
.grid_container {
display: grid;
grid-template-columns: repeat(auto-fill, 150px);
grid-gap: 10px;
justify-content: center;
align-content: flex-start;
margin: 0 auto;
margin-top: 0px;
text-align: center;
margin-top: 10px;
width: 508px;
background: black;
}
.grid_block {
background-color: #269ad3 !important;
color: #efefef;
border: 1px solid #ccc;
width: 150px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
position: relative;
}
.edit-dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
left: 30px;
min-width: 120px;
overflow: auto;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.edit-dropdown-content a {
color: black;
padding: 5px 12px 5px 16px;
text-decoration: none;
display: block;
text-align: left;
font-size: 14px;
}
.w3-right {
float: right !important;
padding: 10px;
}
.w3-xlarge {
font-size: 25px;
}
.show {
display: block;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div id="pdf_parent_id" class="grid_container">
<div class="grid_block">
<div>
<h5>Title</h5>
<i class="fa fa-file-pdf-o"></i>
<h6 style="font-size:12px;">Subtitle</h6>
<div class="w3-right">
<i onclick="myFunction('dropdown_menu0')" class="dropbtn fa fa-ellipsis-v w3-xlarge"></i>
<div id="dropdown_menu0" class="edit-dropdown-content">
<a class="contextMenu"><i class="fa fa-edit"></i> Menu1</a>
<a class="contextMenu"><i class="fa fa-download"></i> Menu2</a>
<a class="contextMenu"><i class="fa fa-share"></i> Menu3</a>
<a class="contextMenu"><i class="fa fa-trash"></i> Menu4</a></div>
</div>
</div>
</div>
<div class="grid_block">
<div>
<h5>Title</h5>
<i class="fa fa-file-pdf-o"></i>
<h6 style="font-size:12px;">Subtitle</h6>
<div class="w3-right">
<i onclick="myFunction('dropdown_menu1')" class="dropbtn fa fa-ellipsis-v w3-xlarge"></i>
<div id="dropdown_menu1" class="edit-dropdown-content">
<a class="contextMenu"><i class="fa fa-edit"></i> Menu1</a>
<a class="contextMenu"><i class="fa fa-download"></i> Menu2</a>
<a class="contextMenu"><i class="fa fa-share"></i> Menu3</a>
<a class="contextMenu"><i class="fa fa-trash"></i> Menu4</a></div>
</div>
</div>
</div>
<div class="grid_block">
<div>
<h5>Title</h5>
<i class="fa fa-file-pdf-o"></i>
<h6 style="font-size:12px;">Subtitle</h6>
<div class="w3-right">
<i onclick="myFunction('dropdown_menu2')" class="dropbtn fa fa-ellipsis-v w3-xlarge"></i>
<div id="dropdown_menu2" class="edit-dropdown-content">
<a class="contextMenu"><i class="fa fa-edit"></i> Menu1</a>
<a class="contextMenu"><i class="fa fa-download"></i> Menu2</a>
<a class="contextMenu"><i class="fa fa-share"></i> Menu3</a>
<a class="contextMenu"><i class="fa fa-trash"></i> Menu4</a></div>
</div>
</div>
</div>
<div class="grid_block">
<div>
<h5>Title</h5>
<i class="fa fa-file-pdf-o"></i>
<h6 style="font-size:12px;">Subtitle</h6>
<div class="w3-right">
<i onclick="myFunction('dropdown_menu3')" class="dropbtn fa fa-ellipsis-v w3-xlarge"></i>
<div id="dropdown_menu3" class="edit-dropdown-content">
<a class="contextMenu"><i class="fa fa-edit"></i> Menu1</a>
<a class="contextMenu"><i class="fa fa-download"></i> Menu2</a>
<a class="contextMenu"><i class="fa fa-share"></i> Menu3</a>
<a class="contextMenu"><i class="fa fa-trash"></i> Menu4</a></div>
</div>
</div>
</div>
We can also use the nth-child selector to target only the one at the end of the row.
function myFunction(id) {
document.getElementById(id).classList.toggle("show");
}
window.onclick = function(event) {
if (!event.target.matches('.dropbtn')) {
var dropdowns = document.getElementsByClassName("edit-dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}
.grid_container {
display: grid;
grid-template-columns: repeat(auto-fill, 150px);
grid-gap: 10px;
justify-content: center;
align-content: flex-start;
margin: 0 auto;
margin-top: 0px;
text-align: center;
margin-top: 10px;
width: 508px;
background: black;
}
.grid_block {
background-color: #269ad3 !important;
color: #efefef;
border: 1px solid #ccc;
width: 150px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
position: relative;
}
.edit-dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
left: 120px;
min-width: 120px;
overflow: auto;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.grid_block:nth-child(3n) .edit-dropdown-content {
left: 30px;
}
.edit-dropdown-content a {
color: black;
padding: 5px 12px 5px 16px;
text-decoration: none;
display: block;
text-align: left;
font-size: 14px;
}
.w3-right {
float: right !important;
padding: 10px;
}
.w3-xlarge {
font-size: 25px;
}
.show {
display: block;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div id="pdf_parent_id" class="grid_container">
<div class="grid_block">
<div>
<h5>Title</h5>
<i class="fa fa-file-pdf-o"></i>
<h6 style="font-size:12px;">Subtitle</h6>
<div class="w3-right">
<i onclick="myFunction('dropdown_menu0')" class="dropbtn fa fa-ellipsis-v w3-xlarge"></i>
<div id="dropdown_menu0" class="edit-dropdown-content">
<a class="contextMenu"><i class="fa fa-edit"></i> Menu1</a>
<a class="contextMenu"><i class="fa fa-download"></i> Menu2</a>
<a class="contextMenu"><i class="fa fa-share"></i> Menu3</a>
<a class="contextMenu"><i class="fa fa-trash"></i> Menu4</a></div>
</div>
</div>
</div>
<div class="grid_block">
<div>
<h5>Title</h5>
<i class="fa fa-file-pdf-o"></i>
<h6 style="font-size:12px;">Subtitle</h6>
<div class="w3-right">
<i onclick="myFunction('dropdown_menu1')" class="dropbtn fa fa-ellipsis-v w3-xlarge"></i>
<div id="dropdown_menu1" class="edit-dropdown-content">
<a class="contextMenu"><i class="fa fa-edit"></i> Menu1</a>
<a class="contextMenu"><i class="fa fa-download"></i> Menu2</a>
<a class="contextMenu"><i class="fa fa-share"></i> Menu3</a>
<a class="contextMenu"><i class="fa fa-trash"></i> Menu4</a></div>
</div>
</div>
</div>
<div class="grid_block">
<div>
<h5>Title</h5>
<i class="fa fa-file-pdf-o"></i>
<h6 style="font-size:12px;">Subtitle</h6>
<div class="w3-right">
<i onclick="myFunction('dropdown_menu2')" class="dropbtn fa fa-ellipsis-v w3-xlarge"></i>
<div id="dropdown_menu2" class="edit-dropdown-content">
<a class="contextMenu"><i class="fa fa-edit"></i> Menu1</a>
<a class="contextMenu"><i class="fa fa-download"></i> Menu2</a>
<a class="contextMenu"><i class="fa fa-share"></i> Menu3</a>
<a class="contextMenu"><i class="fa fa-trash"></i> Menu4</a></div>
</div>
</div>
</div>
<div class="grid_block">
<div>
<h5>Title</h5>
<i class="fa fa-file-pdf-o"></i>
<h6 style="font-size:12px;">Subtitle</h6>
<div class="w3-right">
<i onclick="myFunction('dropdown_menu3')" class="dropbtn fa fa-ellipsis-v w3-xlarge"></i>
<div id="dropdown_menu3" class="edit-dropdown-content">
<a class="contextMenu"><i class="fa fa-edit"></i> Menu1</a>
<a class="contextMenu"><i class="fa fa-download"></i> Menu2</a>
<a class="contextMenu"><i class="fa fa-share"></i> Menu3</a>
<a class="contextMenu"><i class="fa fa-trash"></i> Menu4</a></div>
</div>
</div>
</div>

Add the hover dropdown selection in the tab

I have a problem to do the hover to show the selection in the setting tab, below is my coding:
Original coding:
<div class="topnav">
<span id="curTime" class='hide'> </span>
<div class="btn-group">
<a style="margin-right:20px;" href="#" onclick="setting()" data-toggle="tooltip" data-original-title="Setting" data-placement="bottom" class="btn btn-metis-1 btn-sm">
<i class="fa fa-align-justify"></i>
</a>
<a href="#" onclick="logout()" data-toggle="tooltip" data-original-title="Logout" data-placement="bottom" class="btn btn-metis-1 btn-sm">
<i class="fa fa-power-off"></i>
</a>
</div>
</div>
What I've tried the coding:
<style>
.dropdown-content a:hover {background-color: #ddd;}
.dropdown:hover .dropdown-content {display: block;}
.dropdown:hover .dropbtn {background-color: #3e8e41;}
</style>
<div class="topnav">
<span id="curTime" class='hide'> </span>
<div class="dropdown">
<a class="dropbtn" style="margin-right:20px;" href="#" onclick="setting()" data-toggle="tooltip" data-original-title="Setting" data-placement="bottom" class="btn btn-metis-1 btn-sm">
<i class="fa fa-align-justify"></i>
</a>
<div class="dropdown-content">
test 1
test 2
test 3
</div>
<a href="#" onclick="logout()" data-toggle="tooltip" data-original-title="Logout" data-placement="bottom" class="btn btn-metis-1 btn-sm">
<i class="fa fa-power-off"></i>
</a>
</div>
</div>
My tried coding output show me like below:
My original output show like below:
I want the expected result like below the picture when my mouse pointer move to setting tab:
Hope someone can guide me how to solve this problem. Thanks.
I have added .dropdown-content and .dropdown-content a CSS to generate your desire output. Please see and run the code snippet for details.
Edit 1: Please see the comment for the change details.
/* Add dropdown-content CSS */
.dropdown-content {
display: none;
position: absolute;
min-width: 100px;
z-index: 9;
}
/* Add .dropdown-content a */
.dropdown-content a {
display: block;
background: #f1f1f1;
text-decoration: none;
color: black;
}
/* Edit 1: Add .dropdown */
.dropdown {
display: inline-block; /* Change display from block to inline-block */
}
.dropdown-content a:hover {
background-color: #ddd;
}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown:hover .dropbtn {
background-color: #3e8e41;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="topnav">
<span id="curTime" class='hide'> </span>
<div class="dropdown">
<a class="dropbtn" style="margin-right:20px;" href="#" onclick="setting()" data-toggle="tooltip" data-original-title="Setting" data-placement="bottom" class="btn btn-metis-1 btn-sm">
<i class="fa fa-align-justify"></i>
</a>
<div class="dropdown-content">
test 1
test 2
test 3
</div>
</div>
<!-- Edit 1: Move logout button out of dropdown menu -->
<a href="#" onclick="logout()" data-toggle="tooltip" data-original-title="Logout" data-placement="bottom" class="btn btn-metis-1 btn-sm">
<i class="fa fa-power-off"></i>
</a>
</div>
<div class="dropdown">
<a class="dropbtn" style="margin-right:20px;" href="#" onclick="setting()" data-toggle="tooltip" data-original-title="Setting" data-placement="bottom" class="btn btn-metis-1 btn-sm">
<i class="fa fa-align-justify"></i>
</a>
First of all, you have 2 class attrs in one html tag, put it all in a single one:
<a class="dropbtn btn btn-metis-1 btn-sm" style="margin-right:20px;" href="#" onclick="setting()" data-toggle="tooltip" data-original-title="Setting" data-placement="bottom"
<i class="fa fa-align-justify"></i>
</a>
check if that solve your problem

How to get Responsive Bootstrap Contact Form

I'm very happy with my bootstrap contact form, however when I minimize it down to cellular level it disappears and I have to scroll all the way to the right. Can anyone help me with my CSS to size it down perfectly?
Also, is there any way to make the toggle buttons center when they visible rather than floating to the left.
HTML:
<!DOCTYPE html>
<html>
<head>
<title>Contact</title>
<link href="https://fonts.googleapis.com/css?family=Quicksand" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="contact.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css">
</head>
<body>
<!--navbar-->
<nav class="navbar navbar-expand-sm navbar-dark bg-dark">
<a class="navbar-brand" href="home.html"><img class="avatar" src="images/Originals/avatar.jpg" alt>Munoz Designs</a>
<!--Toggle Button-->
<button class="navbar-toggler" type="button" data-toggle="collapse"data-target="#navbarResponsive"aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span></button>
<!--Navbar links-->
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<li class="nav-item">
<a class="nav-link"
href="about.html">About</a>
</li>
<li class="nav-item">
<a class="nav-link"
href="gallery.html">Gallery</a>
</li>
<!--Social Media Icons-->
<li class="nav-item">
<a class="nav-link" href="https://www.instagram.com/eddiearkmunoz/" title="Follow on Instagram" target="_blank"><i class="fa fa-instagram" aria-hidden="true"></i></a>
<li class="nav-item">
<a class="nav-link" href="https://www.linkedin.com/in/eddie-munoz-351a9428/" title="Follow on Linkedin" target="_blank"><i class="fa fa-linkedin-square" aria-hidden="true"></i></a>
<li class="nav-item">
<a class="nav-link" href="https://twitter.com/arkadiusart" title="Follow on Twitter" target="_blank"><i class="fa fa-twitter" aria-hidden="true"></i></a>
<li class="nav-item">
<a class="nav-link" href="https://eddiemunoz.deviantart.com/gallery/" title="Follow on Deviant Art" target="_blank"><i class="fa fa-deviantart" aria-hidden="true"></i></a>
<li class="nav-item">
<a class="nav-link" href="https://www.artstation.com/ed209" title="Follow on ArtStation" target="_blank"><i class="fa fa-paint-brush" aria-hidden="true"></i></a>
<li class="nav-item">
<a class="nav-link" title="Email">
<i class="fa fa-envelope-o" aria-hidden="true"></i></a>
</ul>
</div>
</div>
</nav>
<div class="intro">
<h1>Contact</h1>
<h4>If you would like to work with me, send me a message!</h4>
</div>
<!--Contact-->
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="well well-sm">
<form class="form-horizontal" method="post">
<fieldset>
<div class="form-group">
<div class="col-md-8">
<div class="input-wrapper">
<input id="fname" name="name" placeholder="Name" type="text" class="form-control">
<label for="fname" class="fa fa-user input-icon bigicon"></label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-8">
<div class="input-wrapper">
<input id="email" name="email" type="text" placeholder="Email" class="form-control">
<label for="email" class="fa fa-envelope-o input-icon bigicon"></label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-8">
<div class="input-wrapper">
<textarea class="form-control" id="message" name="message" placeholder="Message" rows="3"></textarea>
<label for="message" class="fa fa-pencil input-icon bigicon"></label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-12 text-center">
<button type="submit" class="btn btn-outline-secondary btn-md">Submit</button>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
</body>
</html>
html{
box-sizing: border-box;}
*,
*: before,
*: after {
box-sizing: inherit;
padding: 0;
margin: 0;
}
body{background-image: url();
width: 100%;
height: 100%;
background-position: bottom center;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
background-color: #464646;
font-family:"Quicksand";
font-size: 1.2em;
line-height: 1.375em;
padding: 0;
margin: 0;
background-color: #2F3A3B;
overflow-x: hidden;
-webkit-font-smoothing: antialiased;
}
navbar-brand{
height: 3em;
width: 3em;
margin-top: -8px;
border-radius: 5.0em;
margin-right: 1em;
margin-left: -5em;
margin-bottom: -8px
}
.avatar{
border-radius: 5em;
margin-right: .5em;
margin-left: 1em;
}
.intro{
display: inline-block;
width: 100%;
padding: 65px 0 65px;
background-color: #2A2332;
background-size: cover;
font-size: 1.9em;
text-align: center;
color: #FFF;
}
h1{
font-weight: medium;
text-shadow:5px 5px 10px black;
}
h4{
font-size: -.5em;
}
.row{
margin-right: 4em;
margin-left: 4em;
margin-top: .10em;
padding-bottom: -.30em;
}
.container {
margin-left: 17em;
padding-top: 1.5em;
}
.bigicon {
font-size: 35px;
color: #808080;
}
.input-icon {
position: absolute;
left: .5rem;
top: .7rem;
/* Keep icon in center of input, regardless of the input height */
}
#message {
vertical-align: middle;
}
input {
padding-right:30px;
}
.form-control {
text-indent: 2rem;
width: 75%;
}
.input-wrapper {
position: relative;
}
.btn{
margin-right: 10em;
}
#media screen and (min-width: 640px){
}
#media screen and (min-width: 960px){
}
main {flex: 1;}
Perhaps instead of using separate li tags you can use the bootstrap row and column parameters. Try something like this:
<!--Social Media Icons-->
<li class="nav-item">
<div class="row">
<div class="col-xs-2">
<a class="nav-link" href="https://www.instagram.com/eddiearkmunoz/" title="Follow on Instagram" target="_blank"><i class="fa fa-instagram" aria-hidden="true"></i></a>
</div>
<div class="col-xs-2">
<a class="nav-link" href="https://www.linkedin.com/in/eddie-munoz-351a9428/" title="Follow on Linkedin" target="_blank"><i class="fa fa-linkedin-square" aria-hidden="true"></i></a>
</div>
<div class="col-xs-2">
<a class="nav-link" href="https://twitter.com/arkadiusart" title="Follow on Twitter" target="_blank"><i class="fa fa-twitter" aria-hidden="true"></i></a>
</div>
<div class="col-xs-2">
<a class="nav-link" href="https://eddiemunoz.deviantart.com/gallery/" title="Follow on Deviant Art" target="_blank"><i class="fa fa-deviantart" aria-hidden="true"></i></a>
</div>
<div class="col-xs-2">
<a class="nav-link" href="https://www.artstation.com/ed209" title="Follow on ArtStation" target="_blank"><i class="fa fa-paint-brush" aria-hidden="true"></i></a>
</div>
<div class="col-xs-2">
<a class="nav-link" title="Email"><i class="fa fa-envelope-o" aria-hidden="true"></i></a>
</div>
</div>
</li>
I found the answers:
For the contact form to be responsive I deleted the .row in CSS. Once I did that, it was working as a responsive form.
For the toggle buttons to be center, I simply added "text-center" to the collapse property. See below.
<div class="collapse navbar-collapse text-center" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<li class="nav-item">
<a class="nav-link"
href="about.html">About</a>
</li>

set icon and text on image

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>