0

我有两个 div 嵌套在另一个 div 中,无论我尝试了什么,我都无法让第二个嵌套 div(bookmarklet-wrapper)漂浮在第一个(form-wrapper)旁边?我想也许这与宽度有关,但这没有帮助,也尝试使用“clearfix”,但这仍然没有帮助。

我的HTML如下:

<div id="prof-wrapper">    

    <div id="editprofile-form-wrapper">

    <div id="title">
        <h1>Edit Profile</h1>
        <p>This information appears on your personal user page</p>

    </div><!--End of title-->

   <div class="form-horizontal">

            <?php if(isset($image)){echo $image;}?>
        <div id="thumbs" style="width:300px"></div>

            <form id="cropimage" method="post" enctype="multipart/form-data">

               <fieldset class="control-group">
                    <label class="control-label" for="firstname">Firstname</label>
                    <div class="controls">
                            <input id="firstname" type="text" name="fname">
                    </div>
               </fieldset>

               <fieldset class="control-group">
                    <label class="control-label" for="lastname">Surname</label>
                    <div class="controls">
                            <input id="lastname" type="text" name="secound">
                    </div>
               </fieldset>

               <fieldset class="control-group">
                    <label class="control-label" for="email">Email</label>
                    <div class="controls">
                            <input id="email" type="text" name="email">
                    </div>
               </fieldset>

               <fieldset class="control-group">
                    <label class="control-label" for="user_location">Location</label>
                    <div class="controls">
                            <input id="user_location" type="text" value="" name="user[location]">
                            <p>Where art thou?</p>
                    </div>
               </fieldset>

               <fieldset class="control-group">
                    <label class="control-label" for="bio">Bio</label>
                    <div id="user_description_box" class="controls">
                            <textarea id="bio" class="input-xlarge" name="bio" style="width: 243px; height: 122px;"></textarea>
                            <p class="bio-label">About yourself in<strong>160</strong>characters or less.</p>
                    </div>
            </fieldset>

            <div class="form-actions">
                <button id="submitButton" class="btn primary-btn" type="submit" name="submit">Save changes</button>
            </div>

        </form>     

        <form id="cropimage" method="post" enctype="multipart/form-data">

            <fieldset class="control-group">
                    <label class="control-label" for="photoimg">Profile photo upload</label>
                    <div id="user_description_box" class="controls">
                        <input id="photoimg" type="file" value="" name="photoimg">
                        <input type="hidden" name="image_name" id="image_name" value="<?php echo($actual_image_name)?>" />
                        <!--<p class="bio-label">About yourself in <strong>160</strong> characters or less.</p>-->
                    </div>
           </fieldset>

            <div class="form-actions">
                <input type="submit" class="btn primary-btn" id="photoSubmit" name="submit" value="Photo Submit" />
            </div>    

           </form>

        </div><!--End of horizontal form-->

        </div><!--End of form wrapper-->

        <div class="clearfix"></div>

        <!-----------------------------------------Start of bookmarklet-------------------------------------------------->

        <div id="bookmarklet-wrapper">

        <h1 id="welcometext">Welcome to <img src="images/logo_text.png" alt="NetSushi Logo" title="Net Sushi" id="instrustionlogo" width="100px"/></h1>

      <h2 id="bminstructions">The Bookmarklet below should be dragged to your bookmarks bar so that you can share content with your friends on <!--<img src="images/logo_text.png" alt="NetSushi Logo" title="Net Sushi" id="instrustionlogo" width="100px"/>
      <a style="text-decoration:none;
        background:#25A6E1;
        background:-moz-linear-gradient(top,#25A6E1 0%,#188BC0 100%);
        background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#25A6E1),color-stop(100%,#188BC0));
        background:-webkit-linear-gradient(top,#25A6E1 0%,#188BC0 100%);
        background:-o-linear-gradient(top,#25A6E1 0%,#188BC0 100%);
        background:-ms-linear-gradient(top,#25A6E1 0%,#188BC0 100%);
        background:linear-gradient(top,#25A6E1 0%,#188BC0 100%);
        filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#25A6E1',endColorstr='#188BC0',GradientType=0);
        padding:8px 13px;
        color:#fff;
        font-family:'Helvetica Neue',sans-serif;
        font-size:17px;
        border-radius:4px;
        -moz-border-radius:4px;
        -webkit-border-radius:4px;
        border:1px solid #1A87B9;
        position: relative;
        top: 20px;"
        href="javascript:
        (function () {
            function loadjscssfile(filename, filetype){
                if (filetype=='js'){
                    var fileref=document.createElement('script');
                    fileref.setAttribute('type','text/javascript');
                    fileref.setAttribute('id','jsDoc');
                    fileref.setAttribute('src', filename);
                }else if (filetype=='css'){
                    var fileref=document.createElement('link');
                    fileref.setAttribute('rel', 'stylesheet');
                    fileref.setAttribute('id', 'cssDoc');
                    fileref.setAttribute('type', 'text/css');
                    fileref.setAttribute('href', filename);
                }
                if (typeof fileref!='undefined')
                    document.getElementsByTagName('head')[0].appendChild(fileref);
                }
                var cssDoc = document.getElementById('cssDoc');
                if (cssDoc == null){
                    loadjscssfile('http://www.netsushi.net/css/css/bookmarklet.css', 'css');
                }
                var jsDoc = document.getElementById('jsDoc');
                if (jsDoc == null){
                    loadjscssfile('http://www.netsushi.net/js/bookmarklet.js', 'js');
                }else{
                    if ($('#feeder_bm_main').is(':visible')){
                        $('#feeder_bm_main').hide();
                    }else{
                        $('#feeder_bm_main').show();
                    }
                }
            void(0)
        }())
    ;"-->
    >NetSushi</a>

  </div><!--End of bookmarklet wrapper-->




        </div><!--end of edit-page-content-->​

我仍然不确定如何正确格式化我的 CSS 以发布它,但如果你有时间帮助我,你可以确切地看到这个小提琴中发生了什么?

http://jsfiddle.net/DannyW86/3gMuP/

4

3 回答 3

2

如果您只是添加float: left到您的form-wrapper,它应该可以工作:http: //jsfiddle.net/3gMuP/1/

于 2012-11-26T13:15:10.530 回答
2

您也可以使用 display:inline-block; 在您希望彼此相邻的 2 个 div 中。

于 2012-11-26T13:21:28.503 回答
0

这对我有用:

#editprofile-form-wrapper {
  width: 50%;
  float: left;
}

我没有任何其他 CSS 什么的……现在 2 列彼此相邻。

于 2012-11-26T13:23:44.547 回答