html - CSS div 和按钮等高

标签 html css

我有几个按钮,希望将按钮设置为与 queSTList_item 具有相同的高度。我尝试放置相同的 css height:auto; 但高度仍然不相同。知道如何设置等高的按钮吗?谢谢

var questlist = [{
  "startdate": "2015-01-08",
  "questitem": [

    {
      "questid": "1",
      "gifttype": "bbb",
      "quantity": 100,
      "questname": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "queststatus": "ready"
    }, {
      "questid": "2",
      "gifttype": "bbb",
      "quantity": 500,
      "questname": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "queststatus": "done"
    }, {
      "questid": "3",
      "gifttype": "bbb",
      "quantity": 1000,
      "questname": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "queststatus": "complete"
    }, {
      "questid": "4",
      "gifttype": "bbb",
      "quantity": 1200,
      "questname": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "queststatus": "done"
    }, {
      "questid": "5",
      "gifttype": "bbb",
      "quantity": 2200,
      "questname": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "queststatus": "ready"
    },

  ]

}];



questitemlist(questlist);

function questitemlist() {
  var callquest = "<div class='questlist_container'>" +
    "<div id='call_questitem'></div>" +

    "</div>";


  $("#call_quest").append(callquest);
  var questlistobj = questlist[0].questitem;
  $.each(questlistobj, function(i, obj) {
    if (obj.queststatus == "ready") {
      var questlist_item_button = "<input type='button' id='questlist_item_button_go" + obj.questid + "' class='questlist_item_button' id='questlist_item_button' value='GO !'/>";
      $("#call_questitem").on("click", "#questlist_item_button_go" + obj.questid, function() {

      });
      console.log("#questlist_item_button_go" + obj.questid);
    } else if (obj.queststatus == "done") {
      var questlist_item_button = "<input type='button' id='questlist_item_button_reward" + obj.questid + "' class='questlist_item_button' id='questlist_item_button' value='REWARD !'/>";
      $("#call_questitem").on("click", "#questlist_item_button_reward" + obj.questid, function() {

      });
    } else if (obj.queststatus == "complete") {
      var questlist_item_button = "<label class='questlist_item_complete'><img class='questlist_item_img' src='img/check.png'/></label>";

    }

    var questlist_item = "<div class='questlist_item'>" +
      questlist_item_button +
      "<label class='questlist_item_questname'>" + obj.questname + "</label>" +
      "<label class='questlist_item_gifttype'>" + obj.gifttype + " " + obj.quantity + " &#9733;" + "</label>" +
      "</div>";

    $("#call_questitem").append(questlist_item);


  });



}
/* latin */

@font-face {
  font-family: 'Antic';
  font-style: normal;
  font-weight: 400;
  src: local('Antic'), local('Antic-Regular'), url(http://fonts.gstatic.com/s/antic/v7/XHDNSBKb2dlIyyA7tXPbSA.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
/* latin */

@font-face {
  font-family: 'Raleway';
  font-style: normal;
  font-weight: 300;
  src: local('Raleway Light'), local('Raleway-Light'), url(http://fonts.gstatic.com/s/raleway/v9/-_Ctzj9b56b8RgXW8FAriSEAvth_LlrfE80CYdSH47w.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
.questlist_container {
  color: #fff;
  font-family: 'Raleway';
  width: 0 auto;
  height: 0 auto;
  overflow: hidden;
  border: 1px solid #FF1177;
  margin: 0 auto;
  box-shadow: 0 3px 7px rgba(0, 0, 0, .25);
  border-radius: 5px;
  max-width: 100%;
  max-height: 90%;
}
.questlist_container:hover {
  overflow: auto;
  overflow-x: hidden;
}
div::-webkit-scrollbar {
  width: 4px;
}
div::-webkit-scrollbar-track {
  background: #ccc;
  opacity: 0.5;
  position: absolute;
}
div::-webkit-scrollbar-thumb {
  border-radius: 5px;
  background: #FF1177;
  position: absolute;
}
.questlist_item {
  width: 0 auto;
  height: auto;
  background: #ff5ea3;
  border-bottom: 1px solid #fff;
  box-shadow: 0 3px 7px rgba(0, 0, 0, .25);
  padding: 5px 5px 0px 10px;
}
.questlist_item_questname {
  color: #FFC;
  display: list-item;
  height: auto;
  list-style: none;
  font-size: 13px;
}
.questlist_item_gifttype {
  font-size: 11px;
  display: list-item;
  font-weight: bold;
  list-style: none;
  padding-bottom: 5px;
  color: #FCC;
}
.questlist_item_button {
  color: #FF1177;
  font-family: 'Raleway';
  font-size: 13px;
  margin-top: -5px;
  height: auto;
  width: 100px;
  float: right;
  background: #fff;
  border-left: 1px solid #FF1177;
  border-top: none;
  border-bottom: none;
  font-weight: bold;
  margin-right: -13px;
}
.questlist_item_button:hover {
  background: #ff5ea3;
  cursor: pointer;
  color: #fff;
}
.questlist_item_complete {
  margin-top: -5px;
  height: auto;
  width: 99px;
  float: right;
  background: #fff;
  margin-right: -13px;
}
.questlist_item_img {
  margin-top: 15px;
  margin-left: 35px;
}
/*REEEEEEEEEEESPONSIVE*/

@media (max-width: 400px) {
  .questlist_container {
    width: 280px;
  }
  .questlist_item {
    width: 280px;
  }
  .questlist_item_button {
    margin-right: 0px;
  }
  .questlist_item_complete {
    margin-right: 0px;
  }
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="call_quest"></div>

最佳答案

添加到 .question_item - position: relative, padding: 5px 105px 0 0;.queSTList_item_button position: absolute;右:0;顶部:0;高度:100%;

关于html - CSS div 和按钮等高,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28040005/

相关文章:

html - 如何修复 Angular Materials 不起作用的错误

javascript - 我如何使用 Javascript 获取所有子项(即子项的子项)?

html - 动态生成的 super 菜单布局

html - 导航栏链接未正确居中

css - 我不明白为什么我的 CSS 样式会相互干扰?

CSS/HTML 中心框

html - 将动态高度 div 定位在可见屏幕部分的顶部?

html - 把两个 div 一个挨着一个放

html - SVG:多边形内的圆: overflow hidden

css - 在一行中显示 3 个 DIV