How do i get elements to disable when i click on another element?

冷暖自知 提交于 2019-12-06 11:15:29

Not sure if it can break your layout, but it worked adding position:absolute to the #hidden element:

#hidden {
    display:none;
    position: absolute;
    margin-top: -10px;
}

Fiddle. Also added margin-top: -10px because the .box value of -20px was making the div get over the button.

There are a number of CSS things to fix. But the main thing is a combination of position relative and absolute to make the dropdowns position properly.

http://codepen.io/anon/pen/WvLwdx

   #icons {
text-align: center;
}
.comment {
  display: inline-block;
}
.button {
  position: relative;
  display: inline-block;
  margin-right: 5px;
  vertical-align: top;
}
.box {
  position: absolute;
  top: 30px;
  right: 0;
}
.box ul {
  margin: 0;
  background-color: #fff;
}
ul li {
  display: block;
}
.hidden {
  display: none;
}
a {
  padding: 0 !important;
  font-family: Arial;
  font-size: 12px !important;
  text-decoration: underline !important;
  color: #000 !important;
  padding-left: 10px;
}

I have copied all of your code to a jsFiddle, all you need to do is add position: absolute to your .box class like so

jsFiddle : https://jsfiddle.net/g1Lfg7y5/

CSS

#icons {
    width: 450px;
    padding: 0px!important;
}
.comment {
    width: 140px;
    float: right;
}
.button {
    width: 25px;
    display: inline;
    margin-right: 5px;
    vertical-align: top!important;
    height: 25px;
}
.box {
    margin-top: -20px;
    width: 25px;
    position: absolute;
}
.box ul {
    width: 80px;
    height: 35px;
    padding: 10px;
    background-color: #fff;
}
ul.tw {
    border: 0px;
}
li.normal {
    margin-right: 25px!important;
    width: 80px;
}
li.tw {
    margin-right: 60px;
    width: 80px;
}
#hidden {
    display: none;
}
li {
    padding: 0!important;
    list-style-type: none;
    float: right;
}
a {
    padding: 0 !important;
    font-family: Arial;
    font-size: 12px !important;
    text-decoration: underline !important;
    color: #000000 !important;
    padding-left: 10px;
}

I see lots of inconsistencies here.

First of all turn hidden into a class. It repeats itself more than once so it can't be an id.

Then try:

.hidden
{
   display: none;
   position: absolute;
   z-index: 1000;
}

I tested it and it worked.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!