Tips部屋

【Webデザイン】CSSでつまずくポイント。float解除など

えぴぽろ

コーディング初心者がつまずきやすいポイントをメモしています。

わたしがつまずいたら追記していきます。

スポンサーリンク
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- 300 250 --> <ins class="adsbygoogle" style="display:inline-block;width:300px;height:250px" data-ad-client="ca-pub-6265502919566366" data-ad-slot="8794785280"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>

aタグを真ん中に寄せたいとき

「aタグ」はインライン要素のため「margin: 0 auto;」は効きません。
インライン要素をブロック要素にする必要があります。

margin:0 auto;
display:block;
width:100px;  ←ブロック幅に合わせる

これで真ん中になります。

 

floatを解除したいとき

floatされていた要素の次にこれを書く↓


.名前 {
overflow: hidden;;
}

この続きからfloatが解除されます。

 

 
スポンサーリンク
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- 300 250 --> <ins class="adsbygoogle" style="display:inline-block;width:300px;height:250px" data-ad-client="ca-pub-6265502919566366" data-ad-slot="8794785280"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- 300 250 --> <ins class="adsbygoogle" style="display:inline-block;width:300px;height:250px" data-ad-client="ca-pub-6265502919566366" data-ad-slot="8794785280"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>
ABOUT ME
えぴぽろ
えぴぽろ
アニメーター
大阪府在住。 キャラクターデザイナー/アニメーター
記事URLをコピーしました