0

私は次のことを達成しようとしています。コンテンツがある行から別の行に流れる場合はタグを新しい行に移動します。したがって、ここで私が何を意味するかを確認できますhttp://jsfiddle.net/sNyzX/最初の例 (赤) は状況を示しています私は今、2番目の例(オレンジ)は望ましい効果を示していますが、その<br>タグはありません。これはプレーンな html と css で実現できますか? そうでない場合は、jQuery ソリューションでも同様に実現できます。

<div id="example1">
    Hi there This is some text and <a href="#"> this is the link! </a>
</div>

<div id="example2">
    Hi there This is some text and <br> <a href="#"> this is the link! </a>
</div>

CSS:

#example1 {
    background: red;
    width: 145px;
}

#example2 {
    background: orange;
    width: 145px;
    margin-top: 20px;
}
4

5 に答える 5

2

はい、できます!

置くだけ

#example1 a {
    display: block   
}

ここでjsFiddle

于 2013-05-18T13:57:30.250 に答える
1

これをスタイルシートに追加します

#example1 a {
    white-space: nowrap;
}
于 2013-05-18T14:02:37.583 に答える
0

リンクの表示プロパティをブロックに設定するだけで、リンクは常に新しい行に移動します。

#example1 a {
    display: block;
}

このページをチェックして、表示プロパティがどのように機能するかを確認できます: http://www.tutorialrepublic.com/css-tutorial/css-display.php

于 2013-05-20T05:35:28.480 に答える