English 中文(简体)
可扩展的DIV高,以适应内部内容——我究竟做什么错了?
原标题:Expandable DIV height to fit internal content - what am I doing wrong?

Update

解决了这一问题,这是最需要汽车高度的内地,因为我完全忽略了固定高高。


I have - like many others I have searched and found - tried to make an expandable DIV that expands based on the length of it s contents. Mine is a little different from those I have seen so far, as I have variables coming from external Controllers to display, but aside from this what I am trying to achieve is the same. I have created a DIV that contains an image that I repeat-y in the background, however the internal content DIV doesn t want to expand. I will post my code for some clarity -

<div id="feedback_question" class="span-14">
<div id="title_bar">
    <img id="brand_image" src="<?php echo img_path() . $title_row[0]->filename;?>">
    <div id="brand_text">
        <div id="brand_title"><?php echo $title_row[0]->name;?></div>
        <div id="brand_description"><?php echo $title_row[0]->description;?></div>
    </div>
</div>

<div id="background_stretch">
    <div id="question_background">
        <div id="question_tabs" class="span-14">
            <ul id="tab_list">
                <?php for($i = 1; $i <= $maxQuestions; $i++) { ?>
                <li class="tab" id="tab_<?php echo $i; ?>">
                    Q<?php echo $i; ?>
                </li>
                <?php }; ?>
            </ul>
            <div class="question_body">
            <!--Load question template here -->
            <?php echo $questions?>
            </div>
        </div>
    </div>
    <div id="bottom_section">
        <div id="bottom_button_holder">
            <div id="next_button"></div>
        </div>
    </div>
    <br class="clear" />
</div>
<div id="background_bottom">
    <a id="invite_button" href="#"><img src="<?php echo img_path(); ?>feedback/question/invite_button.png"/></a>
</div>

这里是我的国家安全局——

.clear {
    clear: both;
}

.video_multi, .video_multi, .image_multi, .image_multi,  .text_multi, .text_multi {
    display: none;
}

#feedback_question {
     background: transparent url( <?php echo img_path(); ?>feedback/question/question_bg.png ) no-repeat scroll;
     height: auto;
}

#title_bar {
    height: 170px;
    border: 1px solid #EBDDE2;
    background: white;
    width: 501px;
    margin-top: 41px;
    margin-left: 8.5px;
}

#brand_image {
    height: 120px;
    width: 170px;
    border: 2.5px solid #EBDDE2;
    margin: 20px;
    float: left;
}

#brand_text {
    float: right;
    width: 283px;
    height: 150px;
    padding-top: 20px;
}

#brand_title {
    font-size: 28px;
    color: #4365c6;
}

#brand_description {
    width: 280px;
}

#question_tabs {
     background: transparent url( <?php echo img_path(); ?>feedback/question/tab_bar.png ) no-repeat scroll;
     height: 40px;
     padding-top: 22px;
}


#question_background {
     border-left: 1px solid #057eb5;
     border-right: 1px solid #057eb5;
     border-top: 1px solid #057eb5;
     height: 335px;
     width: 501px;
     margin-bottom: -12px;
     overflow: hidden;

}

#tab_list {
    margin-bottom: 5px;
}
.tab {
    background: transparent url( <?php echo img_path(); ?>feedback/question/question_tab_sprite.png ) no-repeat scroll 0 0;
    cursor: pointer;
    display: inline;
    height: 54px;
    list-style: none outside none;
    margin-right: -3px;
    padding-left: 16px;
    padding-right: 13px;
    padding-top: 13px;
    width: 29px;
    color: white;
    font-weight: bold;
}

.tab_hover{
    background-position: 0px -32px;
}

.tab_selected {
    background-position: 0px -64px;
    color: #0881ba;
}


#bottom_button_holder {
    background: transparent url( <?php echo img_path(); ?>feedback/question/question_button_bg.png ) no-repeat scroll;
    height: 47px;
    width: 503px;
    display: block;

}

#next_button {
    background: transparent url( <?php echo img_path(); ?>feedback/question/next_button.png ) no-repeat scroll;
    height: 33px;
    width: 98px;
    display: block;
    position: relative;
    left: 375px;
    top: 5px;
    cursor: pointer;
}

.question_body {
    height: 270px;
    width: 500px;
}

.question_image_holder {
    list-style: none;
    display: inline;
    margin-right: 15px;
    width: 100px;
}

.question_answer_box {
    width: 350px;
    padding-left: 100px;
}

.answer {
    position: relative;
    bottom: 45px;
}

.question {
    margin-left: 5px;
}

.answer_text {
    width: 100px;
}

.answer_list_item {
    list-style: none;
}

#background_stretch {
    background: transparent url( <?php echo img_path(); ?>feedback/question/question_bg_repeat.png ) repeat-y scroll 0 0;
    display: block;
    height:auto;
    padding-left: 8.5px;
}

#background_bottom {
    background: transparent url( <?php echo img_path(); ?>feedback/question/question_bg_bottom.png ) no-repeat scroll;
    display: block;
    height: 90px;
    width: 520px;
    padding-left: 4px;
    padding-top: 20px;

}

#bottom_section {
    position: relative;
    
}

#invite_button {
    background: transparent url( <?php echo img_path(); ?>feedback/question/invite_button.png ) no-repeat scroll;
    display: block;
    height: 52px;
    width: 512px;
    position: relative;

}

Anyway, as you should be able to see, it is my background_stretch and question_background div s that stretches with the content, this all works well and if I change the height of question_background everything moves as it should. However, it s getting question_background to adjust to it s internal contents height that is the problem for me.

我尝试了各种清晰的版本:双管齐下,并铺设不同的箱子,所有这些箱子都无法使用。

我做了什么错误? 我如何做到这一点?

赞赏我得到的任何帮助。

问题回答

添加“可转让”的内容,而不是<代码>:汽车;。 但是,当你赢得高潮时,它就会自动地适合——正如@kos所说的那样。 BTW:你们想要让哪一种多样性能够推广? (如果猜测正确,你想要将四附在<条码>上。

Useful hint: Add You Code to JsFiddle

<代码>#question_background 如果它有固定的高度,它就永远不会改变它内的内容。

另外,在你下台时,请使用jsfiddle.net。 因此,我们可以更容易地测试。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签