2012年02月07日 web関連twitter API

ツイッターのプロフィールウィジェットを入れているサイトで、CSSでデザインしていたら、h3やh4の設定がTwitterのウィジェットにまで反映されて、困ることが時々あります。(私は・・・)

今回はそれを直したかったので、調べて見ました。

Twitterのウィジェット

当サイトでは、Twitterが提供しているコードをそのまま設置していますが、以下のようなコードです。
<script charset="utf-8" src="http://widgets.twimg.com/j/2/widget.js"></script>
<script>
new TWTR.Widget({
  version: 2,
  type: 'profile',
  rpp: 4,
  interval: 10000,
  width: 'auto',
  height: 300,
  theme: {
    shell: {
      background: '#333333',
      color: '#ffffff'
    },
    tweets: {
      background: '#000000',
      color: '#ffffff',
      links: '#4aed05'
    }
  },
  features: {
    scrollbar: false,
    loop: true,
    live: true,
    behavior: 'default'
  }
}).render().setUser('apr_20').start();
</script>

これがHTMLとして表示されると、以下のようになっています。複数のつぶやきが含まれていて複雑だったので、余分な箇所は適当に省いています。

HTMLソース

<div id="twtr-widget-1" class="twtr-widget twtr-widget-profile">
        <div style="width: 100%;" class="twtr-doc">
        <div class="twtr-hd">
        <a class="twtr-profile-img-anchor" href="http://twitter.com/intent/user?screen_name=apr_20" target="_blank"><img src="http://a2.twimg.com/profile_images/1308881356/twitter_normal.jpg" class="twtr-profile-img" alt="profile"></a>
        
        <h3>apr20.net</h3>
        
        <h4><a href="http://twitter.com/intent/user?screen_name=apr_20" target="_blank">apr_20</a></h4>
        
        </div>
        
        <div class="twtr-bd">
        
            <div style="height: 300px;" class="twtr-timeline">
            
                <div class="twtr-tweets">
                
                <div class="twtr-reference-tweet"></div>
                
                <div id="tweet-id-21" class="twtr-tweet" style="opacity: 1; height: 108px;">
                    <div class="twtr-tweet-wrap">
                    
                        <div class="twtr-avatar">
                        
                            <div class="twtr-img"><a href="http://twitter.com/intent/user?screen_name=apr_20" target="_blank"><img src="http://a2.twimg.com/profile_images/1308881356/twitter_normal.jpg" alt="apr_20 profile"></a></div>
                        
                        </div>
                    
                    <div class="twtr-tweet-text">
                    
                    <p>
                    <a class="twtr-user" href="http://twitter.com/intent/user?screen_name=apr_20" target="_blank">apr_20</a> ブログ更新 : Zencartの文字化け対策 - <a rel="nofollow" urlentities="" target="_blank" href="http://t.co/sOSednM8">http://t.co/sOSednM8</a>
                    <em>
                    <a href="http://twitter.com/apr_20/status/166476887701467136" time="Mon Feb 06 11:02:37 +0000 2012" class="twtr-timestamp" target="_blank">5 hours ago</a> ·
                    <a href="http://twitter.com/intent/tweet?in_reply_to=166476887701467136" class="twtr-reply" target="_blank">reply</a> ·
                    <a href="http://twitter.com/intent/retweet?tweet_id=166476887701467136" class="twtr-rt" target="_blank">retweet</a> ·
                    <a href="http://twitter.com/intent/favorite?tweet_id=166476887701467136" class="twtr-fav" target="_blank">favorite</a>
                    </em>
                    </p>
                    </div>
                    </div></div>
                
                <!-- tweets show here -->
                
                </div>
            
            </div>
        </div>
            <div class="twtr-ft">
                <div><a href="http://twitter.com" target="_blank"><img src="http://widgets.twimg.com/i/widget-logo.png" alt=""></a>
                <span><a href="http://twitter.com/apr_20" style="color:#ffffff" class="twtr-join-conv" target="_blank">Join the conversation</a></span>
                </div>
            </div>
        </div>
    </div>

CSSを適用する

上記のようなHTMLソースがわかれば、あとは変更したい箇所にCSSを適用すれば完了です。私の場合は、ウィジェットのヘッド部分にあるh3,h4を修正したかったので、以下のように指定しました。
.twtr-widget h3,.twtr-widget h4{
/*ここにCSSの設定*/
}

この投稿へのコメント

コメントはまだありません。

コメントを残す

メールアドレスが公開されることはありません。

次のHTML タグと属性が使えます。
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CAPTCHA


ピックアップ記事

WordPressのオリジナルテーマのサムネイル作成

2013年11月06日 web関連WordPress
WordPressでオリジナルのテーマを作る時は、テーマ名などはstyle.css内にコメントで設定。 管理画面の外観>テーマのページに表示される、個々のテーマのサムネイル画像は、ファイル名「screenshot」、形式はPNG/JPEG/GIFのどれかにして、サイズは 300×225pxで作成。 http://wordpress.nyamuh.com/cont/base/base.htm…
「WordPressのオリジナルテーマのサムネイル作成」をはてなブックマークに追加

IE9でcss3のtransformが効かない時の解決策

2014年10月30日 web関連HTML5・CSS3
CSS3が使えるようになって、メニューボタンの背景に矢印を表示させることなどが出来るようになりましたが、IEでは効かないものもあります。 背景に矢印を入れる時は、transform: rotate(45deg);のようにborderを回転させるのですが、このtransformがIE9では使えません。 …
「IE9でcss3のtransformが効かない時の解決策」をはてなブックマークに追加

Googleアドセンスがhtml要素を覆い隠してクリック出来ない

2015年03月04日 web関連
Google Adsenseを設置すると隣接する要素をオーバーラップしてしまい、クリック出来なくなる場合の対処法です。 アドセンスが隠してしまってクリック出来ない要素を#navだとすると以下のようにCSSを設定します。 [php]#nav { position:relative; z-index: 100; }[/php]
「Googleアドセンスがhtml要素を覆い隠してクリック出来ない」をはてなブックマークに追加

youtubeで、自動翻訳の字幕を日本語に固定する方法

2021年04月30日 web関連youtube
youtubeで海外のチュートリアル動画などを見ていて、動画が変わるたびに翻訳の設定を、自動翻訳、日本語と設定することが手間だったので、自動翻訳の言語を日本語に固定する方法がないか調べました。 Chromeの拡張機能をつかい、Chrome上でUserSriptを実行させて、Youtubeを開いた時に、スクリプトが自動で、自動翻訳字幕の日本語を選択するといった感じになります。 Windows 1…
「youtubeで、自動翻訳の字幕を日本語に固定する方法」をはてなブックマークに追加

WordPressのサムネイルのサイズ指定を削除

2013年11月10日 web関連WordPressphp
WordPressのテーマ内で、the_post_thumbnailで記事のアイキャッチを表示させる際に、width,heightがimgタグ内で設定されていますが、それを消す方法です。 レスポンシブウェブデザインをする際には、ハードコーディングは外したほうがいいかもしれませんね。 functions.php内に以下を記述 [php]//サムネイルのサイズ指定削除 add_fi…
「WordPressのサムネイルのサイズ指定を削除」をはてなブックマークに追加
© graffiti on the web . All rights reserved. WordPress Theme by comfy