{"id":25759666,"url":"https://github.com/maechabin/jquery.cb-mobileadstyle.js","last_synced_at":"2026-06-09T01:02:18.512Z","repository":{"id":25245425,"uuid":"28670183","full_name":"maechabin/jquery.cb-mobileadstyle.js","owner":"maechabin","description":"スマホ\b広告表示用のjQueryプラグイン","archived":false,"fork":false,"pushed_at":"2015-12-30T11:03:00.000Z","size":2290,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-26T17:44:17.099Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maechabin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-31T16:34:28.000Z","updated_at":"2017-07-11T09:59:33.000Z","dependencies_parsed_at":"2022-07-25T10:17:12.280Z","dependency_job_id":null,"html_url":"https://github.com/maechabin/jquery.cb-mobileadstyle.js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/maechabin/jquery.cb-mobileadstyle.js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maechabin%2Fjquery.cb-mobileadstyle.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maechabin%2Fjquery.cb-mobileadstyle.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maechabin%2Fjquery.cb-mobileadstyle.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maechabin%2Fjquery.cb-mobileadstyle.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maechabin","download_url":"https://codeload.github.com/maechabin/jquery.cb-mobileadstyle.js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maechabin%2Fjquery.cb-mobileadstyle.js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34086664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-26T17:37:39.857Z","updated_at":"2026-06-09T01:02:14.472Z","avatar_url":"https://github.com/maechabin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jQuery.cbMobileAdStyle.js\n\n##＜概要＞\nスマートフォン向けのサイトにバナー広告を表示させる際に、スマホ特有の表示の実装を容易にするjQueryプラグイン。\n\n以下の広告表示スタイルに対応\n\n  - オーバーレイ（サイトの上部、下部に固定表示）\n  - インタースティシャル（アクションが起きた後の、全画面表示）\n  - レスポンシブ（画面サイズに合わせて、アスペクト比を維持したまま伸縮表示）\n  - 高解像度（Retinaディスプレイに対応、画像を縦横サイズ1/2で表示）\n  - トリミング（画面サイズが変更されても、サイズと中央配置を維持したまま表示）\n  - バックグランド（バナーの両端に空いたスペースを背景色で埋めて表示）\n  - ランダム（複数の画像をブラウザーをリロードするたびにランダム表示）\n\n使い方は以下の通り。スタイルを適用させたいバナー広告の要素に対して、メソッドを実行。以下のようにメソッドチェーンして複数のスタイルを適用させることも可能。\n```js\n$(\".selector\").cbInterstitial().cbRetina().cbResponsive();\n```\n\n##\u003c実装の準備\u003e\n\n###1. 外部ファイルを読み込む\n当プラグインのcssファイル、jQuery、当プラグインのjsファイルをページに読み込みます。\n```html\n\u003clink rel=\"stylesheet\" href=\"cbmobileadstyle.css\"\u003e\n\u003cscript src=\"//code.jquery.com/jquery-1.11.0.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"jquery.cbmobileadstyle.min.js\"\u003e\u003c/script\u003e\n```\n\n###2. バナー広告の実装-基本スタイル\n\n  - バナー広告のclass属性に「cb-adstyle」という値を指定。\n  - バナー広告の親要素に任意のselector値を指定。\n\n```html\n\u003c!-- 広告がimgタグの場合 --\u003e\n\u003cdiv class=\"selector\"\u003e\n  \u003ca href=\"バナー広告の飛び先のURL\"\u003e\u003cimg src=\"バナー広告のパス\" class=\"cb-adstyle\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n```\n\n```html\n\u003c!-- 広告がscriptタグの場合 --\u003e\n\u003cdiv class=\"selector\"\u003e\n  \u003cdiv class=\"cb-adstyle\"\u003e\n    \u003cscript src=\"広告表示用のjsファイルのパス\"\u003e\u003c/script\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n```\n\n##\u003cスマホ広告の各スタイル実装方法\u003e\n\n###1. オーバーレイ Overlay\n\nサイトの上部または下部に固定表示させる広告表示スタイル。画面をスクロールしても常に表示され続けるため、クリック率が高くなります。320×50のバナーを使って実装するのが一般的です。\n\n[→オーバーレイのサンプル](http://jsrun.it/maechabin/fO2S)\n\n```js\n$(\".selector\").cbOverlay();\n```\n\n####オプション\n\nデフォルトでは画面下部に固定表示されるようになっていますが、以下のようにオプションを設定すると、画面上部に固定表示させることができます。\n\n```js\n$(\".selector\").cbOverlay({\n  \"position\": \"top\"\n});\n```\n\n###2. インタースティシャル（全画面 / ライトボックス） Interstitial\n\nゲームでのクリア時やWebサイトでのページ遷移時など何かアクションが発生した際に表示させる広告スタイル。全画面いっぱいに表示させるのが一般的です。当プラグインも全画面表示に対応しています。\n\n[→インタースティシャルのサンプル](http://jsrun.it/maechabin/awaV)\n\n```js\n$(\".selector\").cbInterstitial();\n```\n\n\n###3. レスポンシブ Responsive\n\n画面サイズに合わせてバナー広告のサイズもアスペクト比を維持しながら伸縮させて表示させる広告スタイル。\n\n[→レスポンシブのサンプル](http://jsrun.it/maechabin/yjvd)\n\n```js\n$(\".selector\").cbResponsive();\n```\n\n\n###4. 高解像度 Retina\n\n高精細なスマートフォンのディスプレイに対応させる表示スタイル。こちらのスタイルを適用させる場合は、表示サイズの縦横それぞれ倍のサイズのバナー広告を用意します。また、img要素内にサイズの指定もしないでください。\n\n[→高解像度のサンプル](http://jsrun.it/maechabin/r3ic)\n\n```js\n$(\".selector\").cbRetina();\n```\n\n###5. トリミング Triming\n\n画面サイズが変更されても、サイズと中央配置を維持したまま表示させる広告スタイル。\n現在のスマートフォンの画面サイズは大型化してきており、幅320pxのバナーを中央配置しても左右にスペースが入ってしまう場合があります。320pxよりも幅の大きいバナー広告を用意し、こちらのスタイルを適用させることが解決方法の一つとなります。\n\n[→トリミングのサンプル](http://jsrun.it/maechabin/yJdT)\n\n```js\n$(\".selector\").cbTriming();\n```\n\n###6. バックグランド Background\n\nバナーの両端のスペースを背景色で埋める広告スタイル。オーバーレイと一緒に使うことをお勧めします。\nスマートフォンのディスプレイサイズは機種によってさまざまであり、バナーをディスプレイの幅にぴったり合わせて表示させるのは困難になってきています。両端にできたスペースを背景色で埋め、クリック領域を広げます。\n\n[→バックグランドのサンプル](http://jsrun.it/maechabin/4Pthv)\n\n```js\n$(\".selector\").cbBackground();\n```\n\n####オプション\n\n以下のように背景色を任意の色で指定することができます。指定できる値は、CSSのbackground-colorプロパティに指定できる値となります。\n```js\n$(\".selector\").cbBackground({\n  \"bgcolor\": \"#aaa\"\n});\n```\n\n###7. ランダム Random\n\n複数のバナー広告を、ページを表示するたびにランダム表示させる広告スタイル。こちらのスタイルを使用する場合は、必ずランダム表示させたいバナー広告をオプションに指定させます。\n\n[→ランダムのサンプル](http://jsrun.it/maechabin/rQit)\n\n```js\n$(\".selector\").cbRandom({\n\n  ad: [\n    {\n      url: \"バナー広告の飛び先URL 1\",\n      image: \"バナー広告のパス 1\"\n    },\n\n    {\n      url: \"バナー広告の飛び先URL 2\",\n      image: \"バナー広告のパス 2\"\n    }\n\n  ]\n\n});\n```\n\n##\u003c注意点\u003e\n\n上記のメソッドをメソッドチェーンでひとつのバナー広告に対して複数のスタイルを適用させることも可能です。\n\n以下の例は、インタースティシャル広告に高解像度とレスポンシブを適用させた広告スタイルとなります。\n```js\n$(\".selector\").cbInterstitial().cbRetina().cbResponsive();\n```\n\n[→表示サンプル](http://jsrun.it/maechabin/hv4Z)\n\n※ただし、以下のメソッドの組み合わせはお控えください。\n\n- .cbOverlay()と.cbInterstitial()\n- .cbResponsive()と.cbTriming()\n- .cbInterstitial()と.cbBackground()\n\n##\u003cデモ\u003e\n\n[http://jsrun.it/maechabin/gvZm](http://jsrun.it/maechabin/gvZm)\n\n\n##\u003cライセンス\u003e\n\nMIT license\n\n##\u003cアップデート情報\u003e\n\n###ver. 1.1.0\n- バックグランド広告表示対応\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaechabin%2Fjquery.cb-mobileadstyle.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaechabin%2Fjquery.cb-mobileadstyle.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaechabin%2Fjquery.cb-mobileadstyle.js/lists"}