Change submenu (dropdown) direction from vertical to horizontal - html

Right now I have dropdown menus in a vertical direction like this:
I want to change the dropdown menu so that they appear in a horizontal direction, preferred centered of a menu item:
I am using divs (.dropdown, .dropdown-content)
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 16px;
outline: none;
background-image: linear-gradient(#F1F1F1, #E5E5E5);
font-family: inherit;
margin: 0;
width: 150px;
height: 160px;
border: 1px solid white;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}
.dropdown-content {
display: none;
position: absolute;
background-image: linear-gradient(#F1F1F1, #E5E5E5);
border: 1px solid white;
width: 150px;
height: auto;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
padding-bottom: 10px;
}
How can I change the direction and alignment?
<div class="dropdown">
<button class="dropbtn" data-showdiv="CO">
<div class="titleh2">Title</div>
<img class="orga" src="picture.png">
<div class="titleh1">Name</div>
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<a href="#" class="firstImage">
<img class="orga" src="\untitled.png" />
</a>
<div class="titleh2">Title</div><br>
<div class="titleh3">Name</div>
<hr class="horizontal">
<a href="#">
<img class="orga" src="\untitled.png">
</a>
<div class="titleh2">Title</div><br>
<div class="titleh3">Name</div>
<hr class="horizontal">
<a href="#">
<img class="orga" src="\untitled.png">
</a>
<div class="titleh2">Title</div><br>
<div class="titleh3">Name</div>
</div>
</div>

You can use FlexBox to achieve the wanted result. Keep in mind, that flexbox is farily new and not supported in older browsers.
What I did:
Change the display-setting of dropdown-content to display:flex; and added flex-direction: row to align them horizontally.
Then I wrapped all dropdown-elements with a div to give every element of the dropdown some styling in case of need.
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 16px;
outline: none;
background-image: linear-gradient(#F1F1F1, #E5E5E5);
font-family: inherit;
margin: 0;
width: 150px;
height: 160px;
border: 1px solid white;
border-radius: 5px;
}
.dropdown-content {
/*display: none; //Change this to display flex, with the flex-direction to align the items horizontally*/
display: flex;
flex-direction: row;
position: absolute;
background-image: linear-gradient(#F1F1F1, #E5E5E5);
border: 1px solid white;
height: auto;
border-radius: 5px;
padding-bottom: 10px;
}
.dropdown-content-element{
margin: 2px 5px;
padding: 5px;
}
<div class="dropdown">
<button class="dropbtn" data-showdiv="CO">
<div class="titleh2">Title</div>
<img class="orga" src="picture.png">
<div class="titleh1">Name</div>
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<div class="dropdown-content-element">
<a href="#" class="firstImage">
<img class="orga" src="\untitled.png" />
</a>
<div class="titleh2">Title</div>
<div class="titleh3">Name</div>
</div>
<div class="dropdown-content-element">
<a href="#">
<img class="orga" src="\untitled.png">
</a>
<div class="titleh2">Title</div>
<div class="titleh3">Name</div>
</div>
<div class="dropdown-content-element">
<a href="#">
<img class="orga" src="\untitled.png">
</a>
<div class="titleh2">Title</div>
<div class="titleh3">Name</div>
</div>
</div>
</div>
And here is a little cheatsheet to get you started with FlexBox.
EDIT:
This works, but without being centered on the selected supermenu-item. But you'll achieve that yourself, I trust in you!
Oh and by the way: You can sum up your border-radius rules with border-radius: 5px; if all are the same. Saves some space and maintains better readability.
EDIT 2:
Here is an example of using ul and li to achieve a similar result. This method was suggested by #Moose in one of his comments.
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 16px;
outline: none;
background-image: linear-gradient(#F1F1F1, #E5E5E5);
font-family: inherit;
margin: 0;
width: 150px;
height: 160px;
border: 1px solid white;
border-radius: 5px;
}
.dropdown-content {
/*display: none;*/
position: absolute;
background-image: linear-gradient(#F1F1F1, #E5E5E5);
border: 1px solid white;
height: auto;
border-radius: 5px;
padding-bottom: 10px;
}
.dropdown-list {
list-style: none;
}
.dropdown-list>li {
display: inline-block;
}
<div class="dropdown">
<button class="dropbtn" data-showdiv="CO">
<div class="titleh2">Title</div>
<img class="orga" src="picture.png">
<div class="titleh1">Name</div>
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<ul class="dropdown-list">
<li>
<a href="#" class="firstImage">
<img class="orga" src="\untitled.png" />
</a>
<div class="titleh2">Title</div>
<div class="titleh3">Name</div>
</li>
<li>
<a href="#">
<img class="orga" src="\untitled.png">
</a>
<div class="titleh2">Title</div>
<div class="titleh3">Name</div>
</li>
<li>
<a href="#">
<img class="orga" src="\untitled.png">
</a>
<div class="titleh2">Title</div>
<div class="titleh3">Name</div>
</li>
</ul>
</div>
</div>

Related

Why is everything in my sidebar displaced, how do I fix this?

So I've been trying to make my sidebar smaller so that I can make the article bigger, but when I did so it seemed to have displaced everything in the sidebar but I really don't see how. I'm relatively new to html and css so I'm not as experienced and would be really happy if someone could help.
Heres my code:
body {
margin: 0;
background: #fff;
font-family: wayward;
font-weight: 100;
height: 100%;
overflow-x: hidden;
overflow-y: scroll;
display: flex;
flex-wrap: wrap;
padding-top:110px;
max-width: 1600px; margin: auto
}h1 {
margin: 10px;
}
img {
max-width: 100%;
}
.review {
line-height: 29.25px;
padding-top: 5px;
text-align: center;
border-width: 1px;
margin: 10px;
padding: 5px;
word-wrap: break-word;
flex: 1;
}
.text-wrapper{
max-width:800px;
margin:auto;
}
aside .articles{
list-style-type: none;
padding: 0px;
margin-top:0px;
border-top:3px solid;
}
.articles > li.card{
border-left: 1px solid #55d6aa;
border-right: 1px solid #55d6aa;
border-bottom: 1px solid #55d6aa;
}
.articles h3, .articles p {
margin-top: 0px;
}
.articles .content_col{
margin-left: 10px;
}
.image_col{
width:180px;
height:180px;
}
.card{
height:150px;
}
.card-link{
/* remove deafult link color + underline */
color: #55d6aa;
text-decoration: none;
/* change a display from deafult inline to block (all card area is clickbale) */
display: block;
/* transition */
transition: background-color 0.5s ease;
/* flex setting */
display: flex;
align-items: center;
/* extra padding around the card */
padding: 10px;
}
.card-link:hover{
background: #f3f3f3;
}
button {
color: #55d6aa;
background: transparent;
border-width: 2px;
border-style: solid;
border-color: #55d6aa;
position: relative;
margin: 0px;
display: inline-block;
padding: 0.5em 1em;
transition: all 0.3s ease-in-out;
text-align: center;
font-weight: bold;
}
button:before,
button:after {
content: "";
display: block;
position: absolute;
border-color: #55d6aa;
box-sizing: border-box;
border-style: solid;
width: 1em;
height: 1em;
transition: all 0.3s ease-in-out;
}
button:before {
top: -6px;
left: -6px;
border-width: 2px 0 0 2px;
z-index: 5;
}
button:after {
bottom: -6px;
right: -6px;
border-width: 0 2px 2px 0;
}
button {
color: #55d6aa;
border-color: #55d6aa;
}
button:before,
button:after {
border-color: #55d6aa;
}
button:hover:before,
button:hover:after {
width: calc(100% + 12px);
height: calc(100% + 12px);
border-color: #55d6aa;
transform: rotateY(180deg);
}
button:hover {
color: #55d6aa;
background-color: transparent;
border-color: #55d6aa;
}
<aside>
<h2 style="padding:13px;">Most Popular Posts</h2>
<ul class="articles">
<!-- card 1 -->
<li class="card">
<a href="#" class="card-link">
<div class="image_col">
<img src="https://picsum.photos/400/300" />
</div>
<div class="content_col">
<h3>Features</h3>
<p>Responsive Buttons!</p>
<button>Hover me</button>
</div>
</a>
</li>
<!-- card 2 -->
<li class="card">
<a href="#" class="card-link">
<div class="image_col">
<img src="https://picsum.photos/400/301" />
</div>
<div class="content_col">
<h3>Auto NavBar</h3>
<p>Try scrolling up and down!</p>
<button>Read more</button>
</div>
</a>
</li>
<!-- card 3 -->
<li class="card">
<a href="#" class="card-link">
<div class="image_col">
<img src="https://picsum.photos/400/302" />
</div>
<div class="content_col">
<h3>Article heading</h3>
<p>Short description</p>
<button>Read more</button>
</div>
</a>
</li>
<!-- card 4 -->
<li class="card">
<a href="#" class="card-link">
<div class="image_col">
<img src="https://picsum.photos/400/303" />
</div>
<div class="content_col">
<h3>Article heading</h3>
<p>Short description</p>
<button>Read more</button>
</div>
</a>
</li> <!-- card 5 -->
<li class="card">
<a href="#" class="card-link">
<div class="image_col">
<img src="https://picsum.photos/400/304" />
</div>
<div class="content_col">
<h3>Article heading</h3>
<p>Short description</p>
<button>Read more</button>
</div>
</a>
</li> <!-- card 6 -->
<li class="card">
<a href="#" class="card-link">
<div class="image_col">
<img src="https://picsum.photos/400/305" />
</div>
<div class="content_col">
<h3>Article heading</h3>
<p>Short description</p>
<button>Read more</button>
</div>
</a>
</li>
<!-- card 7 -->
<li class="card">
<a href="#" class="card-link">
<div class="image_col">
<img src="https://picsum.photos/400/306" />
</div>
<div class="content_col">
<h3>Article heading</h3>
<p>Short description</p>
<button>Read more</button>
</div>
</a>
</li>
</ul>
</aside>
<div class="review">
<h1>Titanic Movie Review 1996</h1>
<h3>-By Some random guy</h3>
<div class = "thumbnail">
<img src="https://static3.srcdn.com/wordpress/wp-content/uploads/2020/01/Rose-DeWitt-Bukater-and-Jack.png?q=50&fit=crop&w=767&h=450&dpr=1.5" alt="An Image of Jack holding rose from behind">
</div>
<div class = "text-wrapper">
<p>
paragraph here
</p>
</div>
</div>
Hi Just make a small change in your css
.image_col {
width: 180px;
height: auto;}
.card {
height: auto;}

Change behavior/color of function depending on link

I am trying to have sliding-middle-out:hover:after display a different background color depending on the link that is hovered over. I assume there's a way to attach an id# to the function and have it display the color depending on the id that I attached to the html, but I can't figure it out.
html {
position: relative;
min-height: 100%;
}
body {
background: #232526;
background: -webkit-linear-gradient(to right, #232526, #414345);
background: linear-gradient(to right, #232526, #414345);
margin: 0em;
}
a {
cursor: pointer;
cursor: hand;
}
#navbar {
position: fixed;
width: 100%;
top: : 0;
height: 40px;
background: #e4e6e5;
background-color: rgba(228, 230, 229, .8);
border-top: solid transparent 5px;
z-index: 250;
text-align: center;
}
#navbar a {
text-decoration: none;
padding: 0 2% 0 2%;
font-family: sans-serif;
font-size: 12px;
color: #666666;
}
.footer {
position: fixed;
width: 100%;
bottom: 0;
height: 135px;
background: #e4e6e5;
background-color: rgba(228, 230, 229, .8);
-webkit-transform: translateZ(0);
border-top: solid transparent 5px;
z-index: 250;
}
.inline {
display: inline-block;
margin: .5em;
}
.wrap {
display: table;
height: 100px;
width: 360px;
}
#wrap_left {
text-align: left;
}
#wrap_left a {
text-decoration: none;
padding: 0 2% 0 2%;
font-family: sans-serif;
font-size: 12px;
color: #888888;
}
#wrap_right {
text-align: right;
}
.linebreak {
padding-top: 3px;
}
#content {
padding: 50px 0 140px 100px;
}
#sliding-middle-out {
display: inline-block;
position: relative;
padding-bottom: 3px;
}
#sliding-middle-out:after {
content: '';
display: block;
margin: auto;
height: 3px;
width: 0px;
background: transparent;
transition: width .5s ease, background-color .5s ease;
}
#sliding-middle-out:hover:after {
width: 100%;
background: grey;
}
.material-icons.md-14 {
font-size: 14px;
}
<div id="navbar">
<a id="sliding-middle-out" href="Home.html"><i class="material-icons md-14">home</i>Home</a>
<a id="sliding-middle-out" href="Warrior.html"><i class="material-icons md-14">delete_forever</i>Warrior</a>
<a id="sliding-middle-out" href="Druid.html"><i class="material-icons md-14">spa</i>Druid</a>
<a id="sliding-middle-out" href="Priest.html"><i class="material-icons md-14">wifi</i>Priest</a>
<a id="sliding-middle-out" href="Paladin.html"><i class="material-icons md-14">star_half</i>Paladin</a>
<a id="sliding-middle-out" href="Hunter.html"><i class="material-icons md-14">my_location</i>Hunter</a>
<a id="sliding-middle-out" href="Mage.html"><i class="material-icons md-14">whatshot</i>Mage</a>
<a id="sliding-middle-out" href="Shaman.html"><i class="material-icons md-14">nature_people</i>Shaman</a>
<a id="sliding-middle-out" href="Warlock.html"><i class="material-icons md-14">person_outline</i>Warlock</a>
<a id="sliding-middle-out" href="Rogue.html"><i class="material-icons md-14">visibility_off</i>Rogue</a>
<a id="sliding-middle-out" href="Minions.html"><i class="material-icons md-14">keyboard_arrow_up</i>Minions</a>
<a id="sliding-middle-out" href="Spells.html"><i class="material-icons md-14">keyboard_arrow_down</i>Spells</a>
</div>
<!-- navbar -->
<div id="content">
<a href="../Cards/1/Jade_Idol.html">
<img src="../Cards/1/Jade_Idol_S.png">
</a>
<a href="../Cards/1/Mark_of_the_Lotus.html">
<img src="../Cards/1/Mark_of_the_Lotus_S.png">
</a>
<a href="../Cards/3/Celestial_Dreamer.html">
<img src="../Cards/3/Celestial_Dreamer_S.png">
</a>
<a href="../Cards/3/Jade_Blossom.html">
<img src="../Cards/3/Jade_Blossom_S.png">
</a>
<a href="../Cards/3/Pilfered_Power.html">
<img src="../Cards/3/Pilfered_Power_S.png">
</a>
<a href="../Cards/4/Jade_Spirit.html">
<img src="../Cards/4/Jade_Spirit_S.png">
</a>
<a href="../Cards/5/Lotus_Agents.html">
<img src="../Cards/5/Lotus_Agents_S.png">
</a>
<a href="../Cards/5/Lunar_Visions.html">
<img src="../Cards/5/Lunar_Visions_S.png">
</a>
<a href="../Cards/5/Virmen_Sensei.html">
<img src="../Cards/5/Virmen_Sensei_S.png">
</a>
<a href="../Cards/6/Aya_Blackpaw.html">
<img src="../Cards/6/Aya_Blackpaw_S.png">
</a>
<a href="../Cards/6/Jade_Behemoth.html">
<img src="../Cards/6/Jade_Behemoth_S.png">
</a>
<a href="../Cards/10/Kun_the_Forgotten_King.html">
<img src="../Cards/10/Kun_the_Forgotten_King_S.png">
</a>
</div>
<!-- content -->
<center>
<div class="footer">
<div class="inline">
<div class="wrap">
<div id="wrap_right">
<font color="888888" size="4%">CARDSPOILER.COM</font>
<br>
<font color="9B764C" size="3%">Freedom to know</font>
<p></p>
<font size="2%" color="666666">We are here to bring you visual, leaked spoilers for all of the cards you love within a simple gallery setting.</font>
<br>
<font color="#333333">
CONTACT US
PRIVACY POLICY
</font>
</div>
<!-- inline -->
</div>
<!-- wrap -->
</div>
<!-- wrap_left -->
<div class="inline">
<div class="wrap">
<div id="wrap_left">
<td>Mean Streets of Gadgetzan
</td>
<br>
<td>One Night in Karazhan
</td>
<br>
<td>Whispers of the Old Gods
</td>
<br>
<td>The League of Explorers
</td>
<br>
<td>The Grand Tournament
</td>
<br>
<td>Blackrock Mountain
</td>
<br>
</div>
<!-- inline -->
</div>
<!-- wrap -->
</div>
<!-- wrap_left -->
</div>
<!-- footer -->
Like is was said in the comments, IDs must be unique.
You should change #sliding-middle-out to .sliding-middle-out and use it as a class and then add an id to each of those elements.
Something like:
html:
<a id="home" class="sliding-middle-out" href="Home.html"><i class="material-icons md-14">home</i>Home</a>
css:
#home.sliding-middle-out:hover:after {
background-color: blue;
}

In HTML + CSS: Force text to max two rows, increase the width

I have a horizontal timeline made with list (li) elements that has display:flex; at it's parent attribute. That make the list horizontal. But I want the texts to be maximum two rows in the boxes.
So for example, I want this:
The first
asphalt is
delivered.
To become this:
The first asphalt
is delivered.
I want that to be a rule and the width can become as wide as it need to be.
And I have seen a lot of examples where the solution is to work with overflow:hidden. But that's not what I looking for. I wanna know if there is a way to get a dynamic width so all the text is visible.
Edit:
Here is the snippet:
.left-arrow,.right-arrow {
float:left;
width: 0;
height: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
margin-top:20px;
cursor:pointer;
}
.left-arrow {
border-right:20px solid black;
padding-left: 5px;
}
.right-arrow {
border-left:20px solid black;
padding-right: 5px;
}
.timeline {
list-style-type: none;
display: flex;
justify-content: left;
margin: 0 5px;
padding: 0;
float: left;
width: calc(100% - 60px);
overflow-x: scroll;
vertical-align: top;
}
.timeline li {
width: 300px;
vertical-align: top;
}
.timeline li a {
color: #000;
}
.timestamp {
margin-bottom: 10px;
padding: 10px 10px 0;
display: flex;
flex-direction: column;
align-items: center;
white-space: nowrap;
font-weight: 600;
}
.status {
padding: 10px 5px 10px;
display: flex;
justify-content: center;
border-top: 3px solid #000;
position: relative;
font-size: 1.1rem;
}
.status:before {
content: "";
width: 4px;
height: 8px;
background-color: black;
position: absolute;
top: -10px;
left: calc(50% - (4px / 2));
}
<ul class="timeline" id="timeline">
<li>
<a href="#pop-1910-20">
<div class="timestamp">1910-20</div>
<div class="status">The founder buys land.</div>
</a>
</li>
<li>
<a href="#pop-1928">
<div class="timestamp">1928</div>
<div class="status">The refinery goes into operation.</div>
</a>
</li>
<li>
<a href="#pop-1929">
<div class="timestamp">1929</div>
<div class="status">The first asphalt is delivered.</div>
</a>
</li>
<li>
<a href="#pop-1931">
<div class="timestamp">1931</div>
<div class="status">New cracker.</div>
</a>
</li>
<li>
<a href="#pop-1939-45">
<div class="timestamp">1939-45</div>
<div class="status">Central role for the national sales</div>
</a>
</li>
<li>
<a href="#pop-1950s">
<div class="timestamp">1950-talet</div>
<div class="status">The network of petrol stations is being expanded</div>
</a>
</li>
<li>
<a href="#pop-1956">
<div class="timestamp">1956</div>
<div class="status">The second refinery is finished</div>
</a>
</li>
<li>
<a href="#pop-1958">
<div class="timestamp">1958</div>
<div class="status">The founder dies.</div>
</a>
</li>
<li>
<a href="#pop-1960">
<div class="timestamp">1960</div>
<div class="status">Risky sales strategy</div>
</a>
</li>
<li>
<a href="#pop-1967-69">
<div class="timestamp">1967-69</div>
<div class="status">Increased capacity of bitumen</div>
</a>
</li>
<li>
<a href="#pop-1974">
<div class="timestamp">1974</div>
<div class="status">The energy crisis leads to financial crisis</div>
</a>
</li>
</ul>
We can also fix the two lines for li elements by fixing the height and and line-height by halve of it. So two lines only can come but width can be maximum. So that there will be two lines but it would expand on x side. It will be something like this link below.
.twolines{
height: 50px;
line-height: 25px;
width: 100%;
overflow-y: hidden;
}
<ul>
<li class="twolines">Hello World. If it has two lines but have max width it can to be produced so that it will not expanded. Some extra text will be truncated when even two lines exceeded</li>
<li class="twolines">Hello World. If it has two lines but have max width it can to be produced so that it will not expanded.</li>
</ul>
Taken your code snippet and used the same logic of height and line-height. Along with that used box-sizing border box as there was some alignment (like padding and boader) so the width will be controlled including those also.Now only two lines and taken width accrodingly.
.left-arrow,.right-arrow {
float:left;
width: 0;
height: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
margin-top:20px;
cursor:pointer;
}
.left-arrow {
border-right:20px solid black;
padding-left: 5px;
}
.right-arrow {
border-left:20px solid black;
padding-right: 5px;
}
.timeline {
list-style-type: none;
display: flex;
justify-content: left;
margin: 0 5px;
padding: 0;
float: left;
width: calc(100% - 60px);
overflow-x: scroll;
vertical-align: top;
}
.timeline li {
width: 300px;
vertical-align: top;
}
.timeline li a {
color: #000;
}
.timestamp {
margin-bottom: 10px;
padding: 10px 10px 0;
display: flex;
flex-direction: column;
align-items: center;
white-space: nowrap;
font-weight: 600;
}
.status {
padding: 10px 5px 10px;
display: flex;
justify-content: center;
border-top: 3px solid #000;
position: relative;
font-size: 1.1rem;
box-sizing: border-box;
height: 43px;
line-height: 15px;
width: 213px;
}
.status:before {
content: "";
width: 4px;
height: 8px;
background-color: black;
position: absolute;
top: -10px;
left: calc(50% - (4px / 2));
}
<ul class="timeline" id="timeline">
<li>
<a href="#pop-1910-20">
<div class="timestamp">1910-20</div>
<div class="status">The founder buys land.</div>
</a>
</li>
<li>
<a href="#pop-1928">
<div class="timestamp">1928</div>
<div class="status">The refinery goes into operation.</div>
</a>
</li>
<li>
<a href="#pop-1929">
<div class="timestamp">1929</div>
<div class="status">The first asphalt is delivered.</div>
</a>
</li>
<li>
<a href="#pop-1931">
<div class="timestamp">1931</div>
<div class="status">New cracker.</div>
</a>
</li>
<li>
<a href="#pop-1939-45">
<div class="timestamp">1939-45</div>
<div class="status">Central role for the national sales</div>
</a>
</li>
<li>
<a href="#pop-1950s">
<div class="timestamp">1950-talet</div>
<div class="status">The network of petrol stations is being expanded</div>
</a>
</li>
<li>
<a href="#pop-1956">
<div class="timestamp">1956</div>
<div class="status">The second refinery is finished</div>
</a>
</li>
<li>
<a href="#pop-1958">
<div class="timestamp">1958</div>
<div class="status">The founder dies.</div>
</a>
</li>
<li>
<a href="#pop-1960">
<div class="timestamp">1960</div>
<div class="status">Risky sales strategy</div>
</a>
</li>
<li>
<a href="#pop-1967-69">
<div class="timestamp">1967-69</div>
<div class="status">Increased capacity of bitumen</div>
</a>
</li>
<li>
<a href="#pop-1974">
<div class="timestamp">1974</div>
<div class="status">The energy crisis leads to financial crisis</div>
</a>
</li>
</ul>

How to remove an elements active state when a sub element is clicked

I'm currently testing html list using bootstrap and some of my own custom css items. For the last day I have been stuck on how to remove a parents :active state when a sub link is clicked with its own :active state.
Below is a like to my code, I have tried changing z-index, and also tried removing it with jquery with no luck.
My main goal is to keep the list items hover state but once the setting icon is click the item go back to normal view.
Any help would be great.
My Current Code on CodePen
.genericItem, .item img, .item .item-description, .item .item-settings {
display: inline-block;
vertical-align: middle;
}
/*List-group*/
.list-group-item:hover,
.list-group-item:focus {
text-decoration: none;
background-color: whitesmoke;
}
.list-group-item:active {
background-color: #2980b9;
Color: white;
}
/*Items*/
.item {
-webkit-user-select: none;
}
.item .item-description {
margin-left: 5px;
}
.item .item-description p {
margin-top: -4px;
}
.item .item-settings {
color: black;
text-decoration: none;
float: right;
}
.item .item-settings:hover, .item .item-settings:focus {
color: red;
text-decoration: none;
}
.item .item-settings:active {
color: green;
text-decoration: none;
}
.item .item-settings:visited {
color: black;
}
<div class="list-group">
<div class="list-group-item item">
<img src="https://cdn2.iconfinder.com/data/icons/files-color/104/46-files-console-32.png" alt="" />
<div class="item-description">
<h4 class="list-group-item-heading">Dev Console</h4>
<p class="list-group-item-text"><i>Powershell Console, No Profile Loaded</i></p>
</div>
<a class="fa fa-cog item-settings" aria-hidden="true"></a>
</div>
<div class="list-group-item item">
<img src="https://cdn1.iconfinder.com/data/icons/miscellaneous-4/32/toolbox-32.png" alt="" />
<div class="item-description">
<h4 class="list-group-item-heading">Computer Management</h4>
</div>
<a class="fa fa-cog item-settings" aria-hidden="true"></a>
</div>
</div>
You should change your structure of use javascript
here is an example of how I would change the structure
HTML
<div class="list-group">
<div class=" item">
<div class="list-group-item">
<img src="https://cdn2.iconfinder.com/data/icons/files-color/104/46-files-console-32.png" alt="" />
<div class="item-description">
<h4 class="list-group-item-heading">Dev Console</h4>
<p class="list-group-item-text"><i>Powershell Console, No Profile Loaded</i></p>
</div>
</div>
<a class="fa fa-cog item-settings" aria-hidden="true"></a>
</div>
<div class=" item">
<div class="list-group-item item">
<img src="https://cdn1.iconfinder.com/data/icons/miscellaneous-4/32/toolbox-32.png" alt="" />
<div class="item-description">
<h4 class="list-group-item-heading">Computer Management</h4>
</div>
</div>
<a class="fa fa-cog item-settings" aria-hidden="true"></a>
</div>
</div>
And CSS
/*List-group*/
.item > div:hover,
.item > div:focus {
text-decoration: none;
background-color: rgb(245, 245, 245);
}
.item > div:active {
background-color: rgb(41, 128, 185);
Color: white;
}
.item{
position: relative;
}
.item > a{
position: absolute;
right: 15px;
top: 10px;
}
Example : http://codepen.io/anon/pen/aBXGQy?editors=1111

Rearrange buttons in a horizontal line

I am designing a website, and have these menu buttons which will act as like a banner near the top of the page for navigation.
However, at the moment on the website the buttons are in a vertical line. How do i make them horizontal?
here is the button:
button1 {
display: block;
width: 175px;
box-sizing: border-box;
margin: 0.5rem auto;
padding: 0.75rem;
font-size: 1.5rem;
text-align: center;
color: white;
border: solid #ffffff 2px;
background: #8ec8ea;
border-radius: 0.5rem;
outline: none;
cursor: pointer;
}
and my html where ive made the buttons..
<t><button1>Home</button1></t>
<t><button1>Facilities</button1></t>
<t><button1>Facilities</button1></t>
<t><button1>Donate</button1></t>
<t><button1>News</button1></t>
<t><button1>Testimonials</button1></t>
<t><button1>Contact us</button1></t>
Also, if there is better practice of doing this - let me know!
Just change your display: block; to display: inline-block; in your button1 css
JSFiddle: http://jsfiddle.net/ghorg12110/8wzgddhg/1/
And if you want a HTML W3C valid :
HTML:
<div class="t">
<a href="http://tv005382.webs.sse.reading.ac.uk/Lithium/3.-Lithium/app/" class="button1">
Home
</a>
</div>
<div class="t">
<a href="http://tv005382.webs.sse.reading.ac.uk/Lithium/3.-Lithium/app/Facilities.html" class="button1">
Facilities
</a>
</div>
<div class="t">
<a href="http://tv005382.webs.sse.reading.ac.uk/Lithium/3.-Lithium/app/Facilities.html" class="button1">
Facilities
</a>
</div>
<div class="t">
<a href="http://tv005382.webs.sse.reading.ac.uk/Lithium/3.-Lithium/app/Donate.html" class="button1">
Donate
</a>
</div>
<div class="t">
<a href="http://tv005382.webs.sse.reading.ac.uk/Lithium/3.-Lithium/app/News.html" class="button1">
News
</a>
</div>
<div class="t">
<a href="http://tv005382.webs.sse.reading.ac.uk/Lithium/3.-Lithium/app/Testimonials.html" class="button1">
Testimonials
</a>
</div>
<div class="t">
<a href="http://tv005382.webs.sse.reading.ac.uk/Lithium/3.-Lithium/app/Contact.html" class="button1">
Contact us
</a>
</div>
CSS:
.button1 {
width: 175px;
box-sizing: border-box;
margin: 0.5rem auto;
padding: 0.75rem;
font-size: 1.5rem;
text-align: center;
color: white;
border: solid #ffffff 2px;
background: #8ec8ea;
border-radius: 0.5rem;
outline: none;
cursor: pointer;
display: inline-block;
text-decoration: none;
}
.t {
display: inline-block;
}
JSFiddle : http://jsfiddle.net/ghorg12110/8wzgddhg/2/