CSSでボックスの内容物を上下中央揃えにする方法。
.sample {
display: table-cell;
vertical-align: middle;
}
/* IE 7 */
*:first-child+html .sample {
display: inline;
zoom: 1;
}
/*\*//*/
* html .sample {
display: inline-block;
}
/**/
.sample {
display: table-cell;
vertical-align: middle;
}
/* IE 7 */
*:first-child+html .sample {
display: inline;
zoom: 1;
}
/*\*//*/
* html .sample {
display: inline-block;
}
/**/
jQueryでテキストの初期値をフォーカス時に消すには、
下記タグで実現できる
<ul> <li><input type="text" value="ユーザー名" /></li> <li><input type="text" value="メールアドレス" /></li> </ul>
input {
color: #ccc;
}
input .textFocus {
color: #333333 !important;
}
jQuery(document).ready(function(){
// textBox は テキストボックス全てを指定。
var textBox = jQuery("input:text");
// 条件は テキストボックスにフォーカスされたら。
textBox.focus(function(){
// class名 "textFocus" を追加。(文字色を濃くする)
jQuery(this).addClass("textFocus");
// if条件は HTMLで設定した初期値(value)のままかどうか
if(this.value == this.defaultValue){
// trueなら テキストボックスを 空 にする
jQuery(this).val('');
}
// 逆に テキストボックスからフォーカスが失われたとき。
}).blur(function(){
// if条件は テキストボックスの数値が 空(0文字)のとき
if(jQuery(this).val() == ''){
// テキストボックスの中身を 元の初期値(value)にする
// classも外す(文字色を元の薄い色に戻す)
jQuery(this).val(this.defaultValue).removeClass("textFocus");
}
});
});
WordPressで特定のカテゴリーの最新記事を表示するタグは以下の通り
<?php
query_posts('showposts=1&cat=13');
while(have_posts()) : the_post();
?>
<div><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></div>
<div><?php the_content(); ?></div>
<?php endwhile; ?>
WordPressでカテゴリー一覧を表示するには、下記の様に記述する。
<ul> <?php $cat_all = get_terms( "category", "fields=all&get=all&exclude_tree=12&exclude=11" ); foreach($cat_all as $value): ?> <li><a href="<?php echo get_category_link($value->term_id); ?>"><?php echo $value->name;?>(<?php echo $value->count;?>)</a></li> <?php endforeach; ?> </ul>
echo $value->name; //カテゴリ名を出力
echo $value->term_id; //カテゴリIDを出力
echo $value->slug; //カテゴリスラッグを出力
echo $value->count; //カテゴリの投稿数を出力
その他にも、
fields=all&get=all&exclude_tree=12&exclude=11
の部分を変更する事で、取得するカテゴリーを指定することもできる。
Copyright © All Rights Reserved · Green Hope Theme by Sivan & schiy · Proudly powered by WordPress