FROM CACHE - jp_header
このコミュニティはピアツーピアサポートに移行しました。Shopify サポートは今後、このコミュニティへのサービスを提供いたしません。これからもぜひ、他のマーチャントやパートナーとつながり、サポートし合い、経験を共有してください。 当社の行動規範に違反する行動や削除を希望するコンテンツがありましたら、引き続きご報告ください

セクションで複数列を使った際のPCとスマホでテキスト位置を変更したい

解決済

セクションで複数列を使った際のPCとスマホでテキスト位置を変更したい

toot-pm
Shopify Partner
16 0 3

現在DAWNを利用してサイトを作成しております。

 

複数列を利用してコンテンツを作っているのですが、PCとスマホでテキストの表示位置を変更したいのですが、どのようにしてよいかわからず、質問させていただいております。

 

下記画像のようなことを実現したいのですが、お知恵をお貸しいただけますと幸いでございます。

よろしくお願いいたします。

サンプル.jpg

1 件の受理された解決策
Qcoltd
Shopify Partner
1407 545 521

成功

@toot-pm 様

 

記載いただきましたコードをもとにデフォルト状態で、確認いたしましたがコードは問題ございませんでした。

いただいた内容で管理画面より確認すると、添付のように表示され、テキストの上下は詰まっております。

Qcoltd_0-1749016905922.png

 

詰まっていない可能性としては、下記の可能性がございます。

・今回のcss以外でテキスト上下のあきが設定されている。

・管理画面のテキスト入力欄で改行されていて上下が空いている。

 

こちらの場合は、実際のサイトを拝見しないと回答が困難です。

プライベートメッセージ等でサイトをご共有いただけましたら、もう少しわかるかも知れません。

 

(キュー小坂)

株式会社Q (キュー)
グラフィックデザイン、アパレル事業、Web制作など色々やっている渋谷区代々木の会社です。ShopifyでのECサイトの運営・開発も行なっています。
私たちについて: https://web.q-co.jp/ テックブログ: https://techlab.q-co.jp/

元の投稿で解決策を見る

9件の返信9

Qcoltd
Shopify Partner
1407 545 521

@toot-pm 様

 

ご質問内容はキャプションをスマホの際表示位置を変えたいと言う認識で回答させていただきます。

キャプションの位置を変更するには、テーマファイルを編集する必要があります。

 

下記編集方法となります。

 

1.管理画面 > オンラインストア > 「・・・」 > コードを編集をクリック

2.検索窓に「multirow.liquid」を入力しソートされた「multirow.liquid」を開く

3.52行目

<div class="image-with-text__grid grid grid--gapless grid--1-col grid--{% if section.settings.desktop_image_width == 'medium' %}2-col-tablet{% else %}3-col-tablet{% endif %}{% if section.settings.image_layout contains 'alternate' %}{% cycle odd_class, even_class %}{% else %}{{ odd_class }}{% endif %}">

の下に下記コードを追加

<div class="sp-only">
            {%- if block.settings.caption -%}
                <p class="image-with-text__text image-with-text__text--caption caption-with-letter-spacing caption-with-letter-spacing--medium">
                  {{ block.settings.caption | escape }}
                </p>
              {%- endif -%}
              {%- if block.settings.heading -%}
                <h2 class="image-with-text__heading {{ section.settings.heading_size }} rte">
                  {{ block.settings.heading }}
                </h2>
              {%- endif -%}
          </div>

4.上記を追加した場合、90行目あたりにある下記コード

<p class="image-with-text__text image-with-text__text--caption caption-with-letter-spacing caption-with-letter-spacing--medium">

を下記に変更

<p class="image-with-text__text image-with-text__text--caption caption-with-letter-spacing caption-with-letter-spacing--medium pc-only">

5.上記を追加した場合、95行目あたりにある下記コード

<h2 class="image-with-text__heading {{ section.settings.heading_size }} rte">

を下記に変更

<h2 class="image-with-text__heading {{ section.settings.heading_size }} rte pc-only">

6.{% schema %}の上に下記コードを追加

{% style %}
  .sp-only { display:block; }
  .pc-only { display:none; }
  @media only screen and (min-width: 750px) {
   .sp-only { display:none; }
   .pc-only { display:block; }
  }
{% endstyle %}

 

以上でご要望の内容になるかと思われます。

スマホで画像との間をあけたい場合は、.sp-only { display:block; }にmarginや、paddingなどを追加しご調整ください。

 

ご参考まで。

(キュー小坂)

株式会社Q (キュー)
グラフィックデザイン、アパレル事業、Web制作など色々やっている渋谷区代々木の会社です。ShopifyでのECサイトの運営・開発も行なっています。
私たちについて: https://web.q-co.jp/ テックブログ: https://techlab.q-co.jp/
toot-pm
Shopify Partner
16 0 3

回答ありがとうございます!

返信が遅くなり申し訳ございません。

 

教えていただいた通りに対応した結果、思い通りのレイアウトになりました。

あと1点だけご教授いただきたいのですが、出来上がったレイアウトの行幅を詰めたいのですが、どのように修正すればよいでしょうか?

お手数をおかけしますが、ご確認いただけますと幸いでございます。

よろしくお願いいたします。

sample2.jpg

Qcoltd
Shopify Partner
1407 545 521

@toot-pm 様

 

スマホの際、画像下のテキストエリアの上下アキを詰めたい件ですが、

下記CSSを追加いただければ調整可能かと思います。

@media only screen and (max-width: 749px) {
  .image-with-text__content {
    padding-top: 0;
    padding-bottom: 0;
  }
  .image-with-text__text {
    margin-top: 0;
  }
}

 

.image-with-text__contentが画像下のボックス全体にかかっている上下アキを0に、

.image-with-text__textが画像下のテキストの上アキを0にしています。

 

任意のサイズに調整いただければと思います。

 

ご参考まで。

(キュー小坂)

 

株式会社Q (キュー)
グラフィックデザイン、アパレル事業、Web制作など色々やっている渋谷区代々木の会社です。ShopifyでのECサイトの運営・開発も行なっています。
私たちについて: https://web.q-co.jp/ テックブログ: https://techlab.q-co.jp/
toot-pm
Shopify Partner
16 0 3

早速の回答ありがとうございます。

下記のように入れてみたのですが、幅が詰まりません。

入れ場所・ソースが間違っていますでしょうか?

何度もお伺いしてしまい申し訳ございません。

sample3.jpg

よろしくお願いいたします。

Qcoltd
Shopify Partner
1407 545 521

@toot-pm 様

 

入れていただいたコードは問題ないように思われます。

 

デフォルトの設定のままお送りしたコードを追加した場合、

下記添付のように表示されるかと思います。

Qcoltd_0-1748947980789.png

 

実際のコードが分かりましたら、もう少し回答ができるかと思います。

 

(キュー小坂)

株式会社Q (キュー)
グラフィックデザイン、アパレル事業、Web制作など色々やっている渋谷区代々木の会社です。ShopifyでのECサイトの運営・開発も行なっています。
私たちについて: https://web.q-co.jp/ テックブログ: https://techlab.q-co.jp/
toot-pm
Shopify Partner
16 0 3

ありがとうございます。

 

画像ではないので、改行が左詰まりになっていますが、すべてのコードは下記となります。

 

ご確認いただけますと幸いでございます。

 

 

{{ 'component-image-with-text.css' | asset_url | stylesheet_tag }}

{%- style -%}
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
}

@media screen and (min-width: 750px) {
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top }}px;
padding-bottom: {{ section.settings.padding_bottom }}px;
}
}
{%- endstyle -%}

{%- liquid
if section.settings.image_layout contains 'right'
assign odd_class = ' image-with-text__grid--reverse'
else
assign even_class = ' image-with-text__grid--reverse'
endif

if section.settings.row_color_scheme == section.settings.section_color_scheme
assign no_content_background = true
endif

if settings.text_boxes_shadow_opacity == 0 and settings.text_boxes_border_thickness == 0 or settings.text_boxes_border_opacity == 0
assign no_content_styles = true
endif

if settings.text_boxes_border_thickness > 0 and settings.text_boxes_border_opacity > 0 and settings.media_border_thickness > 0 and settings.media_border_opacity > 0
assign borders_class = ' collapse-borders'
endif

if no_content_background and no_content_styles
assign padding_class = ' collapse-padding'
endif

unless no_content_background and no_content_styles
assign corners_class = ' collapse-corners'
endunless
-%}

<div class="multirow section-{{ section.id }}-padding gradient color-{{ section.settings.section_color_scheme }}">
<div class="multirow__inner page-width">
{%- for block in section.blocks -%}
<div
class="image-with-text isolate{{ borders_class }}{{ corners_class }}{{ padding_class }}{% if settings.animations_reveal_on_scroll %} scroll-trigger animate--slide-in{% endif %}"
{{ block.shopify_attributes }}
>
<div class="image-with-text__grid grid grid--gapless grid--1-col grid--{% if section.settings.desktop_image_width == 'medium' %}2-col-tablet{% else %}3-col-tablet{% endif %}{% if section.settings.image_layout contains 'alternate' %}{% cycle odd_class, even_class %}{% else %}{{ odd_class }}{% endif %}">

 

<div class="sp-only">
{%- if block.settings.caption -%}
<div class="image-with-text__text image-with-text__text--caption caption-with-letter-spacing caption-with-letter-spacing--medium">
{{ block.settings.caption | escape }}
</div>
{%- endif -%}
{%- if block.settings.heading -%}
<h2 class="image-with-text__heading {{ section.settings.heading_size }} rte">
{{ block.settings.heading }}
</h2>
{%- endif -%}
</div>

 


<div class="image-with-text__media-item image-with-text__media-item--{{ section.settings.desktop_image_width }} image-with-text__media-item--{{ section.settings.desktop_content_position }} grid__item">
<div
class="image-with-text__media image-with-text__media--{{ section.settings.image_height }} gradient color-{{ section.settings.row_color_scheme }} global-media-settings{% if block.settings.image != blank %} media{% else %} image-with-text__media--placeholder placeholder{% endif %}"
{% if section.settings.image_height == 'adapt' and block.settings.image != blank %}
style="padding-bottom: {{ 1 | divided_by: block.settings.image.aspect_ratio | times: 100 }}%;"
{% endif %}
>
{%- if block.settings.image != blank -%}
{%- capture sizes -%}
(min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 | divided_by: 2 }}px,
(min-width: 750px) calc((100vw - 130px) / 2), calc((100vw - 50px) / 2)
{%- endcapture -%}
{{
block.settings.image
| image_url: width: 1500
| image_tag: sizes: sizes, widths: '165, 360, 535, 750, 1070, 1500'
}}
{%- else -%}
{{ 'detailed-apparel-1' | placeholder_svg_tag: 'placeholder-svg' }}
{%- endif -%}
</div>
</div>
<div class="image-with-text__text-item grid__item">
<div class="image-with-text__content image-with-text__content--{{ section.settings.desktop_content_position }} image-with-text__content--desktop-{{ section.settings.desktop_content_alignment }} image-with-text__content--mobile-{{ section.settings.mobile_content_alignment }} image-with-text__content--{{ section.settings.image_height }} content-container{% unless no_content_background and no_content_styles %} gradient color-{{ section.settings.row_color_scheme }}{% else %} background-transparent{% endunless %}">
{%- if block.settings.caption -%}
<p class="image-with-text__text image-with-text__text--caption caption-with-letter-spacing caption-with-letter-spacing--medium pc-only">

{{ block.settings.caption | escape }}
</p>
{%- endif -%}
{%- if block.settings.heading -%}
<h2 class="image-with-text__heading {{ section.settings.heading_size }} rte pc-only">

{{ block.settings.heading }}
</h2>
{%- endif -%}
{%- if block.settings.text -%}
<div class="image-with-text__text rte {{ section.settings.text_style }}">{{ block.settings.text }}</div>
{%- endif -%}
{%- if block.settings.button_label != blank -%}
<a
{% if block.settings.button_link == blank %}
role="link" aria-disabled="true"
{% else %}
href="{{ block.settings.button_link }}"
{% endif %}
class="button button--{{ section.settings.button_style }}"
>
{{ block.settings.button_label | escape }}
</a>
{%- endif -%}
</div>
</div>
</div>
</div>
{%- endfor -%}
</div>
</div>

{% style %}
.sp-only { display:block; }
.pc-only { display:none; }
@media only screen and (min-width: 750px) {
.sp-only { display:none; }
.pc-only { display:block; }
}

@media only screen and (max-width: 749px) {
.image-with-text__content {
padding-top: 0;
padding-bottom: 0;
}
.image-with-text__text {
margin-top: 0;
}
}

{% endstyle %}


{% schema %}
{
"name": "t:sections.multirow.name",
"class": "section",
"disabled_on": {
"groups": ["header", "footer"]
},
"settings": [
{
"type": "header",
"content": "t:sections.multirow.settings.header.content"
},
{
"type": "select",
"id": "image_height",
"options": [
{
"value": "adapt",
"label": "t:sections.multirow.settings.image_height.options__1.label"
},
{
"value": "small",
"label": "t:sections.multirow.settings.image_height.options__2.label"
},
{
"value": "medium",
"label": "t:sections.multirow.settings.image_height.options__3.label"
},
{
"value": "large",
"label": "t:sections.multirow.settings.image_height.options__4.label"
}
],
"default": "medium",
"label": "t:sections.multirow.settings.image_height.label"
},
{
"type": "select",
"id": "desktop_image_width",
"options": [
{
"value": "small",
"label": "t:sections.multirow.settings.desktop_image_width.options__1.label"
},
{
"value": "medium",
"label": "t:sections.multirow.settings.desktop_image_width.options__2.label"
},
{
"value": "large",
"label": "t:sections.multirow.settings.desktop_image_width.options__3.label"
}
],
"default": "medium",
"label": "t:sections.multirow.settings.desktop_image_width.label"
},
{
"type": "select",
"id": "image_layout",
"options": [
{
"value": "alternate-left",
"label": "t:sections.multirow.settings.image_layout.options__1.label"
},
{
"value": "alternate-right",
"label": "t:sections.multirow.settings.image_layout.options__2.label"
},
{
"value": "align-left",
"label": "t:sections.multirow.settings.image_layout.options__3.label"
},
{
"value": "align-right",
"label": "t:sections.multirow.settings.image_layout.options__4.label"
}
],
"default": "alternate-left",
"label": "t:sections.multirow.settings.image_layout.label"
},
{
"type": "header",
"content": "t:sections.multirow.settings.header_2.content"
},
{
"type": "select",
"id": "heading_size",
"options": [
{
"value": "h2",
"label": "t:sections.all.heading_size.options__1.label"
},
{
"value": "h1",
"label": "t:sections.all.heading_size.options__2.label"
},
{
"value": "h0",
"label": "t:sections.all.heading_size.options__3.label"
},
{
"value": "hxl",
"label": "t:sections.all.heading_size.options__4.label"
},
{
"value": "hxxl",
"label": "t:sections.all.heading_size.options__5.label"
}
],
"default": "h1",
"label": "t:sections.all.heading_size.label"
},
{
"type": "select",
"id": "text_style",
"options": [
{
"value": "body",
"label": "t:sections.multirow.settings.text_style.options__1.label"
},
{
"value": "subtitle",
"label": "t:sections.multirow.settings.text_style.options__2.label"
}
],
"default": "body",
"label": "t:sections.multirow.settings.text_style.label"
},
{
"type": "select",
"id": "button_style",
"options": [
{
"value": "primary",
"label": "t:sections.multirow.settings.button_style.options__1.label"
},
{
"value": "secondary",
"label": "t:sections.multirow.settings.button_style.options__2.label"
}
],
"default": "secondary",
"label": "t:sections.multirow.settings.button_style.label"
},
{
"type": "select",
"id": "desktop_content_position",
"options": [
{
"value": "top",
"label": "t:sections.multirow.settings.desktop_content_position.options__1.label"
},
{
"value": "middle",
"label": "t:sections.multirow.settings.desktop_content_position.options__2.label"
},
{
"value": "bottom",
"label": "t:sections.multirow.settings.desktop_content_position.options__3.label"
}
],
"default": "middle",
"label": "t:sections.multirow.settings.desktop_content_position.label"
},
{
"type": "select",
"id": "desktop_content_alignment",
"options": [
{
"value": "left",
"label": "t:sections.multirow.settings.desktop_content_alignment.options__1.label"
},
{
"value": "center",
"label": "t:sections.multirow.settings.desktop_content_alignment.options__2.label"
},
{
"value": "right",
"label": "t:sections.multirow.settings.desktop_content_alignment.options__3.label"
}
],
"default": "left",
"label": "t:sections.multirow.settings.desktop_content_alignment.label"
},
{
"type": "select",
"id": "mobile_content_alignment",
"options": [
{
"value": "left",
"label": "t:sections.multirow.settings.mobile_content_alignment.options__1.label"
},
{
"value": "center",
"label": "t:sections.multirow.settings.mobile_content_alignment.options__2.label"
},
{
"value": "right",
"label": "t:sections.multirow.settings.mobile_content_alignment.options__3.label"
}
],
"default": "left",
"label": "t:sections.multirow.settings.mobile_content_alignment.label"
},
{
"type": "header",
"content": "t:sections.multirow.settings.header_3.content"
},
{
"type": "color_scheme",
"id": "section_color_scheme",
"label": "t:sections.all.colors.label",
"default": "scheme-1"
},
{
"type": "color_scheme",
"id": "row_color_scheme",
"label": "t:sections.multirow.settings.container_color_scheme.label",
"default": "scheme-1"
},
{
"type": "header",
"content": "t:sections.all.padding.section_padding_heading"
},
{
"type": "range",
"id": "padding_top",
"min": 0,
"max": 100,
"step": 4,
"unit": "px",
"label": "t:sections.all.padding.padding_top",
"default": 36
},
{
"type": "range",
"id": "padding_bottom",
"min": 0,
"max": 100,
"step": 4,
"unit": "px",
"label": "t:sections.all.padding.padding_bottom",
"default": 36
}
],
"blocks": [
{
"type": "row",
"name": "t:sections.multirow.blocks.row.name",
"settings": [
{
"type": "image_picker",
"id": "image",
"label": "t:sections.multirow.blocks.row.settings.image.label"
},
{
"type": "text",
"id": "caption",
"default": "t:sections.multirow.blocks.row.settings.caption.default",
"label": "t:sections.multirow.blocks.row.settings.caption.label"
},
{
"type": "inline_richtext",
"id": "heading",
"default": "t:sections.multirow.blocks.row.settings.heading.default",
"label": "t:sections.multirow.blocks.row.settings.heading.label"
},
{
"type": "richtext",
"id": "text",
"default": "t:sections.multirow.blocks.row.settings.text.default",
"label": "t:sections.multirow.blocks.row.settings.text.label"
},
{
"type": "text",
"id": "button_label",
"default": "t:sections.multirow.blocks.row.settings.button_label.default",
"label": "t:sections.multirow.blocks.row.settings.button_label.label",
"info": "t:sections.multirow.blocks.row.settings.button_label.info"
},
{
"type": "url",
"id": "button_link",
"label": "t:sections.multirow.blocks.row.settings.button_link.label"
}
]
}
],
"presets": [
{
"name": "t:sections.multirow.presets.name",
"blocks": [
{
"type": "row"
},
{
"type": "row"
},
{
"type": "row"
}
]
}
]
}
{% endschema %}

Qcoltd
Shopify Partner
1407 545 521

成功

@toot-pm 様

 

記載いただきましたコードをもとにデフォルト状態で、確認いたしましたがコードは問題ございませんでした。

いただいた内容で管理画面より確認すると、添付のように表示され、テキストの上下は詰まっております。

Qcoltd_0-1749016905922.png

 

詰まっていない可能性としては、下記の可能性がございます。

・今回のcss以外でテキスト上下のあきが設定されている。

・管理画面のテキスト入力欄で改行されていて上下が空いている。

 

こちらの場合は、実際のサイトを拝見しないと回答が困難です。

プライベートメッセージ等でサイトをご共有いただけましたら、もう少しわかるかも知れません。

 

(キュー小坂)

株式会社Q (キュー)
グラフィックデザイン、アパレル事業、Web制作など色々やっている渋谷区代々木の会社です。ShopifyでのECサイトの運営・開発も行なっています。
私たちについて: https://web.q-co.jp/ テックブログ: https://techlab.q-co.jp/
toot-pm
Shopify Partner
16 0 3

ご丁寧に確認いただき、ありがとうございます。

私の方で、ほかCSSが作用していないか、入力欄の改行も含めて調べてみます。

もろもろ調べていただきありがとうございました!

 

toot-pm
Shopify Partner
16 0 3

こちら、どのCSSが影響してるか見つからなかったため、いただいたやり方のCSSに!importantを入れることで、無事に思い通りのレイアウトとなりました。

ありがとうございました!

 

sample4.gif