Add the hover dropdown selection in the tab - html

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

Related

Why Transition css is not working in child selector css

I have created a dropdown in button hover,
I also try the transition css property on my code but its not working to come dropdown smoothly.
This below code is bootstrap dropdown code please suggest me to where i put the right code
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
}
.dropdown:hover > .dropdown-content {
display: block;
top: 35px;
}
<div class="dropdown p-0">
<button type="button" class="btn btn-icon btn-light" data-toggle="dropdown" aria-expanded="false">
dropdown
</button>
<div class="dropdown-arrow"></div>
<ul class="dropdown-menu dropdown-menu-right dropdown-content">
<li> <a class="dropdown-item"><i class="fe fe-file-text mr-2"
aria-hidden="true"></i>Add Task</a></li>
<li> <a class="dropdown-item"><i class="fe fe-zap mr-2"
aria-hidden="true"></i>Add Risk</a></li>
<li> <a class="dropdown-item"><i class="fe fe-trending-up mr-2"
aria-hidden="true"></i>Add Milestone</a></li>
<li> <a class="dropdown-item" ><i class="fe fe-trash-2 mr-2"
aria-hidden="true"></i>Remove Me form This Project</a> </li>
<li> <a class="dropdown-item" ><i class="fe fe-edit mr-2"
aria-hidden="true"></i>Edit</a> </li>
<li> <a class="dropdown-item"><i class="fe fe-check-circle mr-2"
aria-hidden="true"></i>Complete</a></li>
</ul>
</div>
Since you didn't share all the code, first of all you can't add transition at display property, you didn't add transition for top property.
Try to hide .downtown-content with transform: translateY(-100%), and then in hover
transform: translateY(0); transition: all .25s linear (or add your transition here)

Bootstrap Footer: Trouble Centering The Social Media Icons

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

boostrap sidebar collapse in icon when opens first time

I have 2 collapse links, test3 and test
test3 is already collapsed so used in
test is not collapsed has no in
the problem:
this just happen when opens first time I don't know why, the arrow is already down in the link test should not, but after few clicks the arrow backs to work normal.
so test link should be arrow to the left because is not collapsed yet, right now if you see is already to arrow down, someone knows why?
jsfiddle: http://jsfiddle.net/Wc4xt/4399/
HTML:
<div class="sidebar">
<div class="sidebar-wrapper">
<ul class="sidebar-nav">
<li>
<i class="pull-left fa-lg fa fa-book" aria-hidden="true"></i>
<div class="collapse-link">
<a data-toggle="collapse" data-target="#collapseExample1" aria-expanded="false" aria-controls="collapseExample1">test3
</a>
</div>
<div class="collapse in collapse-styled" id="collapseExample1">
<i class="pull-left fa fa-lg fa-list" aria-hidden="true"></i>
test List
<i class="pull-left fa fa-lg fa-list" aria-hidden="true"></i>
Create
</div>
</li>
<li>
<i class="pull-left fa fa-lg fa-book" aria-hidden="true"></i>
<div class="collapse-link">
<a data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">test
</a>
</div>
<div class="collapse collapse-styled" id="collapseExample">
<i class="pull-left fa fa-lg fa-list" aria-hidden="true"></i>
link List
<i class="pull-left fa fa-lg fa-list" aria-hidden="true"></i>
test
</div>
</li>
</ul>
</div>
</div>
CSS:
.sidebar-wrapper {
height: 100%;
overflow-y: auto;
background: #2f3f4d;
-webkit-transition: all 0.5s ease;
transition: all 0.5s ease;
}
.sidebar-nav li {
text-indent: 22px;
line-height: 60px;
border-bottom: 1px solid #455b6f;
}
.sidebar-nav li a {
display: block;
height: 65px;
}
.collapse-link a:after {
font-family: 'Glyphicons Halflings';
content: "\e114";
color: $white;
background-color: black;
}
.collapse-link a.collapsed:after {
content: "\e080";
background-color: red;
}
.collapse-link a.collapsed {
color: white;
}
a {
text-decoration:none;
}
ul li {
list-style:none;
}
As you can see in your CSS, your arrow depends on collapsed class (not in).
You should add collapsed class to you link:
<a class="collapsed" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">test</a>
JSFIDDLE
insert : class="collapsed" in your <a>

Bootstrap anchor element and button with no space between

I'm using Bootstrap 3 and I have a line of buttons. One of them is a <a> button, or: <a class='btn btn-default' role='button'>Button here</a>; the rest are <button> elements with the same classes.
I was expecting to have them all correctly aligned and spaced, as seen in Bootstrap's examples, however, the result was this:
As you can see, the first button, the one specified as <a> doesn't have the right margin with the next button. What can be causing this?
Here's my HTML:
<a class="btn btn-default" role="button">
<i class="fa fa-download" aria-hidden="true"></i> Download Image
</a>
<button class="btn btn-default">
<i class="fa fa-pencil-square-o" aria-hidden="true"></i> Edit Title
</button>
<button class="btn btn-default">Export</button>
<button class="btn btn-danger">Delete</button>
The anchor tags and buttons are correctly spaced because they are inline-block- not sure how there is no spacing between the a and the button you got over there.
Try floating them and then you can remove the space between them if you want to- and set the required margin if needed.
They must be correctly aligned and spaced by default- see below snippet:
a.btn, button.btn {
margin: 0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
<body>
<a class="btn btn-default" role="button">
<i class="fa fa-download" aria-hidden="true"></i> Download Image
</a>
<button class="btn btn-default">
<i class="fa fa-pencil-square-o" aria-hidden="true"></i> Edit Title
</button>
<button class="btn btn-default">Export</button>
<button class="btn btn-danger">Delete</button>
</body>
See what happens when we float them:
a.btn, button.btn {
margin: 0;
float: left;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
<body>
<a class="btn btn-default" role="button">
<i class="fa fa-download" aria-hidden="true"></i> Download Image
</a>
<button class="btn btn-default">
<i class="fa fa-pencil-square-o" aria-hidden="true"></i> Edit Title
</button>
<button class="btn btn-default">Export</button>
<button class="btn btn-danger">Delete</button>
</body>

Limit width on Bootstrap input-group

I'm struggling with a problem for several days now and I couldn't find a solution yet, even though I've tried myself with different approaches, searched google and the mighty stackoverlow for hours.
The set-up:
I've got a panel with two list-groups next to each other, where relations can be managed. On the left are the linked items, on the right all available items that are not linked yet (featuring a pagination and all). The js-logic is working flawless. Clicking on a question-mark does display details for the item. Clicking on a plus moves an item to the left list, clicking on an "x" moves it back to the right. Of course the icons are properly switched, too.
The problem:
The items are user-generated and the form is used both on big and small screens (used bootstrap for that reason).
Some of the items do have a rather long name, limiting the users to keep it short is not an option here. If the text is too long, it just breaks out of the layout.
What I tried so far:
Since the input-groups work with simulating table-elements, I've tried several approaches with table-layout:fixed;, but that doesn't seem to work if it's not really a table. Then I tried several approaches with containing different elements in div-containers and giving them percentual sizes.
It never worked.
Now I'm experimenting with cutting the text server-side, but that looks stupid if the screen is wide enough and the text is cut anyway.
Does someone smarter than me have a solution that makes overflow:hidden; and text-overflow:ellipis; work on those elements?
Here is a (very cleaned-up) fiddle to work with:
https://jsfiddle.net/Fanmade/9vf8xvuL/
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="panel panel-default">
<div class="panel-body">
<div class="row">
<div class="col-md-6">
<ul class="list-group" id="left">
<li class="list-group-item">
<h4 class="text-center">Header Left</h4>
</li>
<li class="list-group-item">
<div class="input-group">
<a href="#" class="btn input-group-addon info-button">
<i class="fa fa-question-circle-o fa-lg"></i>
</a>
<button class="btn btn-default form-control" type=button>
Element 1
</button>
<a href="#" class="btn switch btn-remove input-group-addon">
<i class="fa fa-times fa-lg"></i>
</a>
</div>
</li>
<li class="list-group-item">
<div class="input-group">
<a href="#" class="btn input-group-addon info-button">
<i class="fa fa-question-circle-o fa-lg"></i>
</a>
<button class="btn btn-default form-control" type=button>
Element 2
</button>
<a href="#" class="btn switch btn-remove input-group-addon">
<i class="fa fa-times fa-lg"></i>
</a>
</div>
</li>
<li class="list-group-item">
<div class="input-group">
<a href="#" class="btn input-group-addon info-button">
<i class="fa fa-question-circle-o fa-lg"></i>
</a>
<button class="btn btn-default form-control" type=button>
Element 3
</button>
<a href="#" class="btn switch btn-remove input-group-addon">
<i class="fa fa-times fa-lg"></i>
</a>
</div>
</li>
</ul>
</div>
<div class="col-md-6">
<ul class="list-group" id="left">
<li class="list-group-item">
<h4 class="text-center">Header Right</h4>
</li>
<li class="list-group-item">
<div class="input-group">
<a href="#" class="btn input-group-addon info-button">
<i class="fa fa-plus fa-lg"></i>
</a>
<button class="btn btn-default form-control" type=button>
Element 4
</button>
<a href="#" class="btn switch btn-remove input-group-addon">
<i class="fa fa-question-circle-o fa-lg"></i>
</a>
</div>
</li>
<li class="list-group-item">
<div class="input-group">
<a href="#" class="btn input-group-addon info-button">
<i class="fa fa-plus fa-lg"></i>
</a>
<button class="btn btn-default form-control" type=button>
Element 5 just has a really long text and I don't want to cut it when there is enough space on wide screens
</button>
<a href="#" class="btn switch btn-remove input-group-addon">
<i class="fa fa-question-circle-o fa-lg"></i>
</a>
</div>
</li>
<li class="list-group-item">
<div class="input-group">
<a href="#" class="btn input-group-addon info-button">
<i class="fa fa-plus fa-lg"></i>
</a>
<button class="btn btn-default form-control" type=button>
Element 6
</button>
<a href="#" class="btn switch btn-remove input-group-addon">
<i class="fa fa-question-circle-o fa-lg"></i>
</a>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
Edit after the answers:
Thank you both so much for the answer!
I'm feeling so stupid right now. Of course the answer had to be so simple and I was just searching in the wrong direction.
The working fiddle is
https://jsfiddle.net/sesn/y98pz4hj/1/
Here is your answer
button { white-space: normal !important; height: auto !important; }
It will work :
button {
white-space: normal !important;
height: auto !important;
}