Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
したがって、私の画像は1920px x 150pxです。ブラウザ画面が1920px未満になると、画像は画面の中央に残り、画像の左右から同量のピクセルを自動的に非表示にする必要があります。
たとえば、ブラウザの合計幅が 1520 ピクセルの場合、左から 200 ピクセル、右から 200 ピクセルを非表示にする必要があります (常に画像を中央に配置したくありません)。
これを行う方法はありますか?
前もって感謝します
<IMG>タグで画像を使用する代わりに、 のbackgroundとして使用しdiv、 classimgBGを指定して、次のスタイルを含めます。
<IMG>
background
div
imgBG
.imgBG{ background: url(images/imagename.jpg) no-repeat 50% top; width: 100%; height: 150px; margin: auto; }