画面サイズ適応のためのメディア クエリ
複数の画面サイズに合わせて Web レイアウトを設計する場合、メディア クエリは不可欠なツールになります。これらのクエリを使用すると、開発者は画面の幅に基づいてレイアウトを調整する方法を指定できます。
特定の画面サイズにメディア クエリを適用する
特定の画面サイズをターゲットにするには、次のメディア属性を使用します。 max-width プロパティ。たとえば、幅が 800 ピクセル未満の画面にスタイルを適用するには、次を使用します。
@media screen and (max-width: 800px) { /* Styles for screens less than 800px wide */ }
提供されたコード サンプルの使用
提供されたコード サンプルでは、次のメディア クエリを使用します。
/* Smartphones (portrait and landscape) */ @media only screen and (min-device-width : 320px) and (max-device-width : 480px) { /* Styles for smartphones in portrait and landscape */ } /* Smartphones (landscape) */ @media only screen and (min-width : 321px) { /* Styles for smartphones in landscape */ } /* Smartphones (portrait) */ @media only screen and (max-width : 320px) { /* Styles for smartphones in portrait */ } /* iPads (portrait and landscape) */ @media only screen and (min-device-width : 768px) and (max-device-width : 1024px) { /* Styles for iPads in portrait and landscape */ } /* iPads (landscape) */ @media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) { /* Styles for iPads in landscape */ } /* iPads (portrait) */ @media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) { /* Styles for iPads in portrait */ } /* Desktops and laptops */ @media only screen and (min-width : 1224px) { /* Styles for desktops and laptops */ } /* Large screens */ @media only screen and (min-width : 1824px) { /* Styles for large screens */ } /* iPhone 4 - 5s */ @media only screen and (-webkit-min-device-pixel-ratio : 1.5), only screen and (min-device-pixel-ratio : 1.5) { /* Styles for iPhone 4 - 5s */ } /* iPhone 6 */ @media only screen and (max-device-width: 667px) only screen and (-webkit-device-pixel-ratio: 2) { /* Styles for iPhone 6 */ } /* iPhone 6+ */ @media only screen and (min-device-width : 414px) only screen and (-webkit-device-pixel-ratio: 3) { /* Styles for iPhone 6+ */ } /* Samsung Galaxy S7 Edge */ @media only screen and (-webkit-min-device-pixel-ratio: 3), and (min-resolution: 192dpi)and (max-width:640px) { /* Styles for Samsung Galaxy S7 Edge */ }
これらのメディア クエリは、スマートフォン、タブレットなどの幅広い画面サイズをカバーします。
その他の考慮事項
さまざまな画面サイズでの柔軟性を高めるために、ピクセルの代わりに em 値を使用することを検討してください。詳細については、Zell Weekley による記事「Media Query Units」を参照してください。
以上がメディア クエリは、さまざまな画面サイズに対応したレスポンシブ Web サイトの設計にどのように役立ちますか?の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

FlexBoxまたはグリッドの選択は、レイアウト要件によって異なります。1)FlexBoxは、ナビゲーションバーなどの1次元レイアウトに適しています。 2)グリッドは、雑誌のレイアウトなどの2次元レイアウトに適しています。この2つは、レイアウト効果を改善するためにプロジェクトで使用できます。

CSSファイルを含める最良の方法は、タグを使用してHTMLパーツに外部CSSファイルを導入することです。 1.タグを使用して、外部CSSファイルを導入します。 2。小さな調整のために、インラインCSSを使用できますが、注意して使用する必要があります。 3.大規模プロジェクトでは、@Importを介して他のCSSファイルをインポートするために、SASS以下などのCSSプリプロセッサを使用できます。 4。パフォーマンスのために、CSSファイルをマージし、CDNを使用し、CSSNANOなどのツールを使用して圧縮する必要があります。

はい、Youはrelearnbothlexboxandgrid.1)FlexBoxisidealforone-Dimensional、FlexiblleayoutslikenavigationMenus.2)Gridexcelsintwo-digsignssuchasmagazinelayouts.3)Bothenhanceslaysutibulivedibulisunivedivition、floctonsulururを

独自のコードをリファクタリングするのはどのように見えますか?ジョン・レアは、彼が書いた古いCSSアニメーションを選び、それを最適化するという思考プロセスを歩きます。

cssanimationsArenotintinlentyhardbutrepracticeanderstanding ofcsspropertiesandtimingfunctions.1)

@keyframesispopularduetoitsversitility andpowerincreatingsmoothcssanimations.keytricksinclude:1)defingsmoothtransitionsbetweenstates、2)AnimatingMultipleProperiessimally、3)3)bendorprefixesforbrows -compativity、4)組み合わせwithjavasfo

csScounterSareSareusedTomageautomaticinginginwebdesigns.1)それらは、コンテンツ、リスト、および積極的なものを使用することができます

特にモバイルデバイスでは、スクロールシャドウを使用することは、Chrisが以前にカバーした微妙なUXです。 Geoffは、アニメーションタイムラインプロパティを使用する新しいアプローチをカバーしました。これがさらに別の方法です。


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

Dreamweaver Mac版
ビジュアル Web 開発ツール

MantisBT
Mantis は、製品の欠陥追跡を支援するために設計された、導入が簡単な Web ベースの欠陥追跡ツールです。 PHP、MySQL、Web サーバーが必要です。デモおよびホスティング サービスをチェックしてください。

SublimeText3 中国語版
中国語版、とても使いやすい

SublimeText3 英語版
推奨: Win バージョン、コードプロンプトをサポート!
