我有几个按钮,希望设置按钮与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 + " ★" + "</label>" +
"</div>";
$("#call_questitem").append(questlist_item);
});
}
&#13;
/* 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;
}
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="call_quest"></div>
&#13;
答案 0 :(得分:1)
如果我对您的问题的理解是正确的,您可以使用此CSS使按钮与其容器具有相同的高度
.questlist_item {
/* your current style */
position: relative;
}
.questlist_item_button{
/* your current style */
display: block;
position: absolute;
height: 100%;
right: 0;
}
答案 1 :(得分:1)
添加到.question_item - position: relative, padding: 5px 105px 0 0;
和.questlist_item_button position: absolute; right: 0; top: 0; height: 100%;