0

I'm trying to assign margin-left:20px to all divs inside a form, whose class contains edit, with the following:

form.edit > div  {
    margin-left:20px;
}

My idea was that: form identifies the element, .edit identifies all the forms with the edit class assigned, and that > div sets the style for all the div child items. but it is not working, so I must be wrong! Any idea of how achieving this?

PS here's the html, I would like to assign the above style to the last div in the following code (id="address"):

<form class="edit" action="edit.php" method="post" name="edit" id="edit" enctype="multipart/form-data">
  <div class="row">
   <ul class="breadcrumb">
        <li>Data</li>
   </ul>   
   <div class="span8 well">
    <input type="text" name="lastname" id="lastname" class="span7">
    <div id="address">
        // many more divs after this one
4

1 に答える 1

3

>は直接の子孫の識別子であるため、以下では、最上位レベルのみがcssによって割り当てられます。

<form class="edit">
    <div>
        <div>
        </div>
    </div>
</form>

を削除する>と、スタイルがフォームの下のすべてのdivに適用されます。

于 2012-10-27T00:15:15.143 に答える