2017-09-05 6 views
1

CSSのタグの配置に問題があります。私が何を試しても、それは主要部分の下に残り、上には行かない(私は右上隅が必要)。どこに問題があるのか​​分からない。助けてください。ここで 左上にタグを置くことはできません。左端/上端:0、左端:0などのオプションはありません。

.aside { 
 
     position: relative; 
 
     float: right; 
 
     margin: 14px 14px 14px 0px; 
 
     padding-left: 15px; 
 
     clear: left; 
 
     width: 220px; 
 
     background-color: #EAA845; 
 
    } 
 

 
    .sectionaside { 
 
     padding: 10px; 
 
     margin: 15px 15px 15px 5px; 
 
     background-color: #DF5252; 
 
    }
<aside class="aside"> 
 

 
      <section class="sectionaside"> 
 
      <h4><u>Liked the article?! Stay tuned and find more interesting insights!</u></h4> 
 
      
 
      </section> 
 

 
      <section class="sectionaside"> 
 
      <h4>Related web sites</h4> 
 
      
 
      </section> 
 

 
      <section class="sectionaside"> 
 
      <h4>A &quot;must have&quot; skills in 21st century</h4> 
 
      
 

 
      </section> 
 

 
     </aside> 
 

 

 
     <footer><u>Contact information</u></footer>

答えて

1

使用してみて、問題の一部と私のCSSコードであるposition: absoluteタグ上またはposition: fixed(ウィンドウへスティック)(それは<body>に対して配置する必要がある場合) topまたはleftのプロパティ

1

あなたのCSSでは、あなたはすぐ下に浮かんでいます。それは浮動するように変更する必要があります。浮動要素を完成させた後にclearfixを作成するのがよい方法です。コードの変更内容を添付のスニペットで確認してください。それが役に立てば幸い。

.aside { 
 
    position: relative; 
 
    float: left; 
 
    margin: 14px 14px 14px 0px; 
 
    padding-left: 15px; 
 
    clear: left; 
 
    width: 220px; 
 
    background-color: #EAA845; 
 
} 
 

 
.sectionaside { 
 
    padding: 10px; 
 
    margin: 15px 15px 15px 5px; 
 
    background-color: #DF5252; 
 
} 
 
.clearfix{ 
 
    clear:both; 
 
}
<aside class="aside"> 
 

 
     <section class="sectionaside"> 
 
     <h4><u>Liked the article?! Stay tuned and find more interesting insights!</u></h4> 
 

 
     </section> 
 

 
     <section class="sectionaside"> 
 
     <h4>Related web sites</h4> 
 

 
     </section> 
 

 
     <section class="sectionaside"> 
 
     <h4>A &quot;must have&quot; skills in 21st century</h4> 
 

 

 
     </section> 
 

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

 
    <footer><u>Contact information</u></footer>

+0

動作しませんでしたが、おかげで –

0

あなたはasideは、他のすべての上になりたい場合は、単にどんな要素にclear: both;を追加すると後に来る - あなたの特定のケースフッターではなく、実際の生活の中で、おそらく何かを。

そして、あなたが本当に右上コーダーでそれをしたい場合は、それをmargin設定を消去し、htmlbodymargin: 0;を追加します。

html, 
 
body { 
 
    margin: 0; 
 
} 
 

 
.aside { 
 
    position: relative; 
 
    float: right; 
 
    padding-left: 15px; 
 
    clear: left; 
 
    width: 220px; 
 
    background-color: #EAA845; 
 
} 
 

 
.sectionaside { 
 
    padding: 10px; 
 
    margin: 15px 15px 15px 5px; 
 
    background-color: #DF5252; 
 
} 
 

 
footer { 
 
    clear: both; 
 
}
<aside class="aside"> 
 

 
    <section class="sectionaside"> 
 
    <h4><u>Liked the article?! Stay tuned and find more interesting insights!</u></h4> 
 

 
    </section> 
 

 
    <section class="sectionaside"> 
 
    <h4>Related web sites</h4> 
 

 
    </section> 
 

 
    <section class="sectionaside"> 
 
    <h4>A &quot;must have&quot; skills in 21st century</h4> 
 

 

 
    </section> 
 

 
</aside> 
 

 

 
<footer><u>Contact information</u></footer>

関連する問題