13

ブラウザーのサイズが変更された場合、または異なるサイズのデバイスで、すべて意味的に関連する html 要素のセットが必要です。つまり、要素の 1 つがグループ全体を含めるのに十分な幅がないために次の「行」に移動する場合、そのすべてが下に移動する必要があります。

IOW、これは、ワード プロセッシング ドキュメント内のアイテムの一部のグループが持つ「まとめて保持」属性のようなものです。

もう少し具体的に言うと、次の要素のコレクションがあるとします。

1) an anchor tag, filling out a first "column"
2) a collection of tags, to the right of the anchor tag, consisting of:
(a) a div, followed by a <br/>
(b) a cite, followed by a <br/>
(c) another div, followed by a <br/>
(d) two or three anchor tags that are aligned side-by-side at the bottom of the second "column"

要約すると、「行」の 2 番目の「列」に十分なスペースがない場合は、最初の「列」を保持して 2 番目の列の要素を次の「行」に移動するのではなく、最初の列では、その兄弟に準拠し、常にそれらと同じ「行」にとどまる必要があります(HTMLテーブルを使用していないため、「行」と「列」を引用符で囲んでいます。それらは仮想感覚)。

これを視覚化するのが少し難しいと感じた場合 (私はあなたを責めません)、フィドルをチェックしてください: http://jsfiddle.net/W7CYC/8/

注: グループ化を html5 s にラップしても役に立ちませんでした。

コードは次のとおりです。

HTML:

<div class="yearBanner">2013</div>
<section>
<a id="mainImage" class="floatLeft" href="https://rads.stackoverflow.com/amzn/click/com/0299186342" rel="nofollow noreferrer"><img height="240" width="160" src="http://ecx.images-amazon.com/images/I/51usxIl4vML._SY346_.jpg"></a>

    <div id="prizeCategory" class="category">BIOGRAPHY</div>
    <br/>
<cite id="prizeTitle" class="title">Son of the Wilderness: The Life of John Muir</cite>

    <br/>
    <div id="prizeArtist" class="author">Linnie Marsh Wolfe</div>
    <br/>
    <img class="floatLeft" height="60" width="40" src="http://ecx.images-amazon.com/images/I/51usxIl4vML._SY346_.jpg">
    <img class="floatLeft" height="60" width="40" src="http://ecx.images-amazon.com/images/I/51usxIl4vML._SY346_.jpg">
    <img class="floatLeft" height="60" width="40" src="http://ecx.images-amazon.com/images/I/51usxIl4vML._SY346_.jpg">
</section>
<section>
<a class="floatLeft" href="https://rads.stackoverflow.com/amzn/click/com/0299186342" rel="nofollow noreferrer"><img height="240" width="160" src="http://ecx.images-amazon.com/images/I/51usxIl4vML._SY346_.jpg"></a>

    <div class="category">BIOGRAPHY</div>
    <br/>
<cite class="title">Son of the Wilderness: The Life of John Muir</cite>

    <br/>
    <div class="author">Linnie Marsh Wolfe</div>
    <br/>
    <img height="60" width="40" src="http://ecx.images-amazon.com/images/I/51usxIl4vML._SY346_.jpg">
    <img height="60" width="40" src="http://ecx.images-amazon.com/images/I/51usxIl4vML._SY346_.jpg">
    <img height="60" width="40" src="http://ecx.images-amazon.com/images/I/51usxIl4vML._SY346_.jpg">
</section>

CSS:

body {
    background-color: black;
}
.floatLeft {
    float: left;
    padding-right: 20px;
    padding-left: 5px;
}
.yearBanner {
    font-size: 3em;
    color: white;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    float: left;
    padding-top: 64px;
}
.category {
    display: inline-block;
    font-family: Consolas, sans-serif;
    font-size: 2em;
    color: Orange;
    width: 160px;
}
.title {
    display: inline-block;
    font-family: Calibri, Candara, serif;
    color: Yellow;
    width: 160px;
}
.author {
    display: inline-block;
    font-family: Courier, sans-serif;
    font-size: 0.8em;
    color: White;
    width: 160px;
}

jQuery:

$('#prizeCategory').text("Changed Category");
$('#prizeTitle').text("Changed Title that spans two rows");
$('#prizeArtist').text("Changed Author and co-author");
$('#mainImage img').attr("src", "http://ecx.images-amazon.com/images/I/61l0rZz6mdL._SY300_.jpg");
$('#mainImage img').attr("height", "200");
4

3 に答える 3

12

アイテムを単純にグループ化しますdiv(または、 を使用したい場合はsection、それも問題ありません)。CSSの少しのヒントで、アイテムをラッパー内にグループ化できます。残念ながら、まとめて保持するような属性はありませんが、次のことができます。

section.wrapper {
  min-width: 400px; /* Minimum width of your wrapper element */
  overflow: hidden;
  display: inline-block;
}

min-widthは、ラッパー内の要素を順番に保つのに役立ちます。状況に最も適した値を選択してください。値が非表示の
オーバーフローにより、ラッパーは浮動要素の幅と高さの値を理解し、内部に追加できます。値inline-blockを指定して表示すると、十分なスペースがある限り、すべてのラッパーを隣り合わせに並べることができます。十分なスペースがない場合、ラッパーは他の行にジャンプします。

http://www.w3schools.com/は、CSS、HTML、および Web 技術全般を理解して学習するための優れた情報源を提供します。非常に便利。

編集
私が編集したように、その状況では最大幅よりも最小またはの方が適しています

于 2013-06-16T00:09:22.873 に答える