This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="wrap"> | |
<p><?php echo post_meta($post->ID, '{TEXT}', true ); ?></p> | |
</div> |
アンカータグ<a></a>を使うと width 指定した div.wrapからはみ出たりする。
そこで、cssで以下のように white-spaceをしてする。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
div.wrap a { | |
white-space: pre; /* CSS 2.0 */ | |
white-space: pre-wrap; /* CSS 2.1 */ | |
white-space: pre-line; /* CSS 3.0 */ | |
white-space: -pre-wrap; /* Opera 4-6 */ | |
white-space: -o-pre-wrap; /* Opera 7 */ | |
white-space: -moz-pre-wrap; /* Mozilla */ | |
white-space: -hp-pre-wrap; /* HP Printers */ | |
word-wrap: break-word; /* IE 5+ */ | |
} |
すると、通常や改行や半角スペースがひとつにまとめられてしまうところ
改行や半角文字として認識してくれる!
http://www.htmq.com/style/white-space.shtml
ただし、
<p>
ちわー
</p>
とか無駄なインデントや改行もそのまま反映されるので、その辺は注意ですね。
0 件のコメント:
コメントを投稿