0

我有标记:

http://jsfiddle.net/ZVXFD/85/

我需要制作.step100% 的父容器,如何做到这一点。html:

 <div class="steps-container">
        <div class="group">
            <div class="step">
                <ul class="sortable">
                    <li class="item">Item</li>
                    <li class="item">Item</li>
                    <li class="item">Item</li>
                    <li class="item">Item</li>
                    <li class="item">Item</li>
                </ul>
            </div>
            <div class="step">
                <ul class="sortable">
                    <li class="item">Item</li>
                    <li class="item">Item</li>
                    <li class="item">Item</li>
                    <li class="item">Item</li>
                    <li class="item">Item</li>
                    <li class="item">Item</li>

                </ul>
            </div>
            <div class="step">
                <ul class="sortable">
                    <li class="item">Item</li>
                    <li class="item">Item</li>
                </ul>
            </div>
        </div>

    </div>

CSS:

* {
    margin: 0px;
    padding: 0px;
}

ul {
    list-style-type: none;
    margin: 0px;
    padding: 0px;
    display: inline-block;
}

.sortable li {
    margin: 0px;
    padding: 0px;
    width: 100px;
    height: 100px;
    border: 1px solid black;
    background-color: lightgrey;
}


.group {
    display:inline-block;
    border: 1px solid red;
}

.step {
    border: 1px solid green;
    display:inline-block;
    background-color: yellow;
}

.item {
    background-color: lightgray;
}
4

2 回答 2

1

你可以设置position: relative;.group

position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;

.step

我假设您.step当时只显示一个元素,我错了吗?

于 2012-12-06T17:26:55.920 回答
0

http://jsfiddle.net/ZVXFD/94/

如果您希望 .group 为 100% 宽,则需要以下样式:

.group {
    border: 1px solid red;
    display:table; /* make the element 100% fill the entire available width */
    width: 100%;
}

如果您希望 .step 等高,则需要以下样式:

.step {
    border: 1px solid green;
    display:table-cell; /* make the element 100% of its parent's height/equal height columns */
    background-color: yellow;
}
于 2012-12-06T18:59:02.600 回答