﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>webコーディング  |  Web Creators Hub</title>
	<atom:link href="https://web-creators-hub.com/category/web-cording/feed/" rel="self" type="application/rss+xml" />
	<link>https://web-creators-hub.com</link>
	<description>WEB技術などの情報をわかりやすく配信するメディア</description>
	<lastBuildDate>Wed, 08 Feb 2023 01:56:31 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.8.2</generator>
	<item>
		<title>【flex縦レイアウト】高さを指定せず真ん中伸ばして底の要素を固定し余白埋める</title>
		<link>https://web-creators-hub.com/web-cording/flex-grow/</link>
		<pubDate>Tue, 23 Apr 2019 14:01:55 +0000</pubDate>
		<dc:creator><![CDATA[taizo]]></dc:creator>
				<category><![CDATA[webコーディング]]></category>

		<guid isPermaLink="false">https://web-creators-hub.com/?p=239</guid>
		<description><![CDATA[flex-growで余白をコントロール 下のような縦レイアウトで真ん中の要素を伸ばして底の要素を固定したいときflexを使うと簡単に実現でき...]]></description>
				<content:encoded><![CDATA[<p><img src="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/flex_grow.png" alt="" width="700" height="350" class="alignnone size-full wp-image-243" srcset="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/flex_grow.png 700w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/flex_grow-300x150.png 300w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/flex_grow-320x160.png 320w" sizes="(max-width: 700px) 100vw, 700px" /></p>
<h2>flex-growで余白をコントロール</h2>
<p>下のような縦レイアウトで真ん中の要素を伸ばして底の要素を固定したいときflexを使うと簡単に実現できます。flexboxは余白の部分をどこの要素に割り当てられるかを指定できます。このようにflexはいままで厄介だった余白をコントロールできる特徴をもっています。floatの代わりだけではありません。</p>
<p><strong>html</strong></p>
<pre class="brush: xml; title: ; notranslate">
  &lt;ul class=&quot;Container&quot;&gt;
    &lt;li class=&quot;Container__item&quot;&gt;
      &lt;dl class=&quot;ImgBox&quot;&gt;
        &lt;dt class=&quot;ImgBox__block&quot;&gt;&lt;img class=&quot;ImgBox__block-img&quot; src=&quot;sample.jpg&quot; alt=&quot;わんこ&quot;&gt;&lt;/dt&gt;
        &lt;dd class=&quot;ImgBox__text&quot;&gt;テストテストテストテストテス&lt;/dd&gt;
        &lt;dd class=&quot;ImgBox__date&quot;&gt;2019/04/23&lt;/dd&gt;
      &lt;/dl&gt;
    &lt;/li&gt;
    &lt;li class=&quot;Container__item&quot;&gt;
      &lt;dl class=&quot;ImgBox&quot;&gt;
        &lt;dt class=&quot;ImgBox__block&quot;&gt;&lt;img class=&quot;ImgBox__block-img&quot; src=&quot;sample.jpg&quot; alt=&quot;わんこ&quot;&gt;&lt;/dt&gt;
        &lt;dd class=&quot;ImgBox__text&quot;&gt;
          テストテストテストテストテストテストテストテストテストテストテストテストテストトテストテストテストテストテストテストテストテスト
          テストテストテストテストテストテストテストテストテストテストテストテストテストトテストテストテストテストテストテストテストテスト
        &lt;/dd&gt;
        &lt;dd class=&quot;ImgBox__date&quot;&gt;2019/04/23&lt;/dd&gt;
      &lt;/dl&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
</pre>
<p><img class="alignnone size-full wp-image-240" src="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/flex_column2.png" alt="" width="717" height="472" srcset="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/flex_column2.png 717w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/flex_column2-300x197.png 300w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/flex_column2-320x211.png 320w" sizes="(max-width: 717px) 100vw, 717px" /></p>
<p>日付の部分を右の要素のように底に固定する感じにしたい。flexを日付の部分の余白をImgBox__textクラスに割り当てるといい感じになりそうです。割り当てる方法は「flex-grow」を使うと割り当てることができます。</p>
<p><img src="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/flex_column.png" alt="" width="723" height="477" class="alignnone size-full wp-image-241" srcset="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/flex_column.png 723w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/flex_column-300x198.png 300w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/flex_column-320x211.png 320w" sizes="(max-width: 723px) 100vw, 723px" /></p>
<p><strong>html</strong></p>
<pre class="brush: xml; title: ; notranslate">
  &lt;ul class=&quot;Container&quot;&gt;
    &lt;li class=&quot;Container__item&quot;&gt;
      &lt;dl class=&quot;ImgBox&quot;&gt;
        &lt;dt class=&quot;ImgBox__block&quot;&gt;&lt;img class=&quot;ImgBox__block-img&quot; src=&quot;sample.jpg&quot; alt=&quot;わんこ&quot;&gt;&lt;/dt&gt;
        &lt;dd class=&quot;ImgBox__text&quot;&gt;テストテストテストテストテス&lt;/dd&gt;
        &lt;dd class=&quot;ImgBox__date&quot;&gt;2019/04/23&lt;/dd&gt;
      &lt;/dl&gt;
    &lt;/li&gt;
    &lt;li class=&quot;Container__item&quot;&gt;
      &lt;dl class=&quot;ImgBox&quot;&gt;
        &lt;dt class=&quot;ImgBox__block&quot;&gt;&lt;img class=&quot;ImgBox__block-img&quot; src=&quot;sample.jpg&quot; alt=&quot;わんこ&quot;&gt;&lt;/dt&gt;
        &lt;dd class=&quot;ImgBox__text&quot;&gt;
          テストテストテストテストテストテストテストテストテストテストテストテストテストトテストテストテストテストテストテストテストテスト
          テストテストテストテストテストテストテストテストテストテストテストテストテストトテストテストテストテストテストテストテストテスト
        &lt;/dd&gt;
        &lt;dd class=&quot;ImgBox__date&quot;&gt;2019/04/23&lt;/dd&gt;
      &lt;/dl&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
</pre>
<p><strong>CSS</strong></p>
<pre class="brush: css; title: ; notranslate">
.ImgBox {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-direction: column;
      flex-direction: column;
  height: 100%;
}
.ImgBox__block {
  margin: 0 0 10px;
}
  .ImgBox__block-img {
    width: 100%;
  }
.ImgBox__text {
  -ms-flex-positive: 1;
      flex-grow: 1;
  margin: 0 0 10px;
}
.ImgBox__date {
  text-align: right;
}
</pre>
<p><strong>SCSS</strong></p>
<pre class="brush: css; title: ; notranslate">
.ImgBox{
	display: flex;
	flex-direction: column;
	height: 100%; //これがないと機能しない
	&amp;__block{
		margin: 0 0 10px;
		&amp;-img{
			width: 100%;
		}
	}
	&amp;__text{
		flex-grow: 1; //余白を割り当てる
		margin: 0 0 10px
	}
	&amp;__date{
		text-align: right;
	}
}
</pre>
<p>flex-growは余白の部分をどの要素にどれくらい分配するか指定することのできるプロパティです。計算方法はflexアイテムのflex-growの合計を求め、その合計値の数だけ余白を分割し指定した要素に分配します。今回の場合はImgBox__textクラスに1、ほかの要素は指定していませんので(デフォルトは0)余白の部分は分割されずにそのままImgBox__textクラスに余白全てを割り当てるという意味になります。</p>
<h2>flex-grow: 1 をすべてのアイテムに指定した場合</h2>
<p><img src="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/flex_column3.png" alt="" width="720" height="528" class="alignnone size-full wp-image-242" srcset="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/flex_column3.png 720w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/flex_column3-300x220.png 300w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/flex_column3-320x235.png 320w" sizes="(max-width: 720px) 100vw, 720px" /><br />
flex-growを使うと簡単に余白をコントロールできます。</p>
]]></content:encoded>
			</item>
		<item>
		<title>【PHPなし】CSSで長い文字列を省略！末尾を三点リーダー[…]にし崩れ防止する</title>
		<link>https://web-creators-hub.com/web-cording/text-overflow/</link>
		<pubDate>Mon, 22 Apr 2019 15:50:17 +0000</pubDate>
		<dc:creator><![CDATA[taizo]]></dc:creator>
				<category><![CDATA[webコーディング]]></category>

		<guid isPermaLink="false">https://web-creators-hub.com/?p=233</guid>
		<description><![CDATA[動的に記事を出力するとき、通常であればPHPを使って文字列を省略してきました。しかしPHPがわからない、仕事でシステムの人に頼むのも面倒。そ...]]></description>
				<content:encoded><![CDATA[<p><img src="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/text-overflow_2.png" alt="" width="700" height="350" class="alignnone size-full wp-image-235" srcset="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/text-overflow_2.png 700w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/text-overflow_2-300x150.png 300w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/text-overflow_2-320x160.png 320w" sizes="(max-width: 700px) 100vw, 700px" /></p>
<p>動的に記事を出力するとき、通常であればPHPを使って文字列を省略してきました。しかしPHPがわからない、仕事でシステムの人に頼むのも面倒。そのような人に持って来いなのが今回の省略技です。なんとCSSを使って文字列を省略することができるのです。今回はこの方法をご紹介します。</p>
<h2>text-overflow</h2>
<p>このプロパティは、ボックスに収まらない文章の表示方法を指定できます。そして表示方法を「ellipsis」に指定するとはみ出して表示されない文字列を省略します。</p>
<p><img src="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/text-overflow.png" alt="" width="337" height="361" class="alignnone size-full wp-image-234" srcset="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/text-overflow.png 337w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/text-overflow-280x300.png 280w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/text-overflow-320x343.png 320w" sizes="(max-width: 337px) 100vw, 337px" /></p>
<h2>使用方法</h2>
<p>省略したい文字列の要素にクラス「is-text-overflow」を追加するだけ。</p>
<p><strong>html</strong></p>
<pre class="brush: xml; title: ; notranslate">
&lt;div class=&quot;Contents&quot;&gt;
  &lt;div class=&quot;Container&quot;&gt;
    &lt;div class=&quot;Container__text is-text-overflow&quot;&gt;
      長い長い長い長い長い文字列を省略します。
      長い長い長い長い長い文字列を省略します。
      長い長い長い長い長い文字列を省略します。
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</pre>
<p><strong>CSS</strong></p>
<pre class="brush: css; title: ; notranslate">
.Container {
  width: 300px;
  margin: 30px;
  padding: 30px;
  border: 1px solid #666;
}
.is-text-overflow {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
</pre>
<p><strong>SCSS</strong></p>
<pre class="brush: css; title: ; notranslate">
.Container{
	width: 300px;
	margin: 30px;
	padding: 30px;
	border:1px solid #666;
}
.is-text-overflow{
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
</pre>
]]></content:encoded>
			</item>
		<item>
		<title>CSSを使ってマウスオーバー(hover)で画像の拡大する</title>
		<link>https://web-creators-hub.com/web-cording/hover-scale/</link>
		<pubDate>Mon, 22 Apr 2019 14:45:34 +0000</pubDate>
		<dc:creator><![CDATA[taizo]]></dc:creator>
				<category><![CDATA[webコーディング]]></category>

		<guid isPermaLink="false">https://web-creators-hub.com/?p=220</guid>
		<description><![CDATA[transform:scale(1.3) マウスオーバーのアクションは色を反転させたり、少し透明にしたりいろんなアクションがあります。今回は...]]></description>
				<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-228" src="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/transform-scale.png" alt="" width="700" height="350" srcset="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/transform-scale.png 700w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/transform-scale-300x150.png 300w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/transform-scale-320x160.png 320w" sizes="(max-width: 700px) 100vw, 700px" /></p>
<h2>transform:scale(1.3)</h2>
<p>マウスオーバーのアクションは色を反転させたり、少し透明にしたりいろんなアクションがあります。今回はCSSだけを使いマウスオーバー(hover)時に画像が拡大するアクションを紹介します。</p>
<p>Javascriptを使わないのでやり方は簡単。マウスオーバーする要素に画像を入れ「transform:scale(1.3)」を追加する。アニメーションにしたいので値の変化をアニメーションさせる「transition-duration」を使う。</p>
<pre class="brush: xml; title: ; notranslate">
&lt;div class=&quot;Contents&quot;&gt;
  &lt;div class=&quot;Contents__img&quot;&gt;
    &lt;a class=&quot;is-hover-scale&quot; href=&quot;sample.html&quot;&gt;
     &lt;dl class=&quot;ImgTextBox&quot;&gt;
       &lt;dt class=&quot;ImgTextBox__wrap is-overflow-hidden&quot;&gt;
        &lt;img class=&quot;ImgTextBox__wrap-img&quot; src=&quot;sample.jpg&quot; alt=&quot;わんこ&quot;&gt;
       &lt;/dt&gt;
       &lt;dd class=&quot;ImgTextBox__text&quot;&gt;hoverすると画像が拡大するサンプル&lt;/dd&gt;
     &lt;/dl&gt;
   &lt;/a&gt;
  &lt;/div&gt;
&lt;/div&gt;
</pre>
<p><strong>SCSS</strong></p>
<pre class="brush: css; title: ; notranslate">
.ImgTextBox{
	width: 500px;
	margin: 20px;
	padding: 20px;
	border: 1px solid #666;
	&amp;__wrap{
		width: 100%;
	}
	&amp;__text{
		padding: 15px;
		font-size: 20px;
		text-align: center;
	}
}
//hover
.is-hover-scale{
	&amp;:hover{
		img{
			transform:scale(1.3);
			transition-duration: 0.3s;
		}
	}
}
.is-overflow-hidden{
	overflow: hidden;
}
</pre>
<p><strong>CSS</strong></p>
<pre class="brush: css; title: ; notranslate">
.ImgTextBox {
  width: 500px;
  margin: 20px;
  padding: 20px;
  border: 1px solid #666;
}
.ImgTextBox__wrap {
  width: 100%;
}
.ImgTextBox__text {
  padding: 15px;
  font-size: 20px;
  text-align: center;
}
.is-hover-scale:hover img {
transform: scale(1.3);
transition-duration: 0.3s;
}
.is-overflow-hidden {
overflow: hidden;
}
</pre>
<h2>使用方法</h2>
<p><img class="alignnone size-full wp-image-223" src="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/is-hover-use.png" alt="" width="737" height="648" srcset="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/is-hover-use.png 737w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/is-hover-use-300x264.png 300w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/is-hover-use-320x281.png 320w" sizes="(max-width: 737px) 100vw, 737px" /></p>
<p>追加するとこんな感じ<br />
<img alt="" src="/image/is-hover-scale.gif" /></p>
<h2>上記のように黒くする方法</h2>
<p>クラス「is-overflow-hidden」を追加した要素にクラス「-bg-black」を追加。クラス「is-hover-scale」を追加した要素にクラス「-opacity」を追加。</p>
<p><strong>html</strong></p>
<pre class="brush: xml; title: ; notranslate">
&lt;div class=&quot;Contents&quot;&gt;
  &lt;div class=&quot;Contents__img&quot;&gt;
    &lt;a class=&quot;is-hover-scale -opacity&quot; href=&quot;sample.html&quot;&gt;
     &lt;dl class=&quot;ImgTextBox&quot;&gt;
       &lt;dt class=&quot;ImgTextBox__wrap is-overflow-hidden -bg-black&quot;&gt;
         &lt;img class=&quot;ImgTextBox__wrap-img&quot; src=&quot;sample.jpg&quot; alt=&quot;わんこ&quot;&gt;
       &lt;/dt&gt;
       &lt;dd class=&quot;ImgTextBox__text&quot;&gt;hoverすると画像が拡大するサンプル&lt;/dd&gt;
     &lt;/dl&gt;
   &lt;/a&gt;
  &lt;/div&gt;
&lt;/div&gt;
</pre>
<p><strong>CSS</strong></p>
<pre class="brush: css; title: ; notranslate">
.ImgTextBox {
  width: 500px;
  margin: 20px;
  padding: 20px;
  border: 1px solid #666;
}
.ImgTextBox__wrap {
  width: 100%;
}
.ImgTextBox__text {
  padding: 15px;
  font-size: 20px;
  text-align: center;
}
.is-hover-scale:hover img {
transform: scale(1.3);
transition-duration: 0.3s;
}
.is-hover-scale.-opacity:hover img {
opacity: 0.6;
}
.is-overflow-hidden {
overflow: hidden;
}
.is-overflow-hidden.-bg-black {
  background: #000;
}
</pre>
<p><strong>SCSS</strong></p>
<pre class="brush: css; title: ; notranslate">
.ImgTextBox{
	width: 500px;
	margin: 20px;
	padding: 20px;
	border: 1px solid #666;
	&amp;__wrap{
		width: 100%;
	}
	&amp;__text{
		padding: 15px;
		font-size: 20px;
		text-align: center;
	}
}
.is-hover-scale{
	&amp;:hover{
		img{
			transform:scale(1.3);
			transition-duration: 0.3s;
		}
	}
	&amp;.-opacity{
		&amp;:hover{
			img{
				opacity: 0.6;
			}
		}
	}
}
.is-overflow-hidden{
	overflow: hidden;
	&amp;.-bg-black{
		background: #000;
	}
}
</pre>
]]></content:encoded>
			</item>
		<item>
		<title>【gif有】pointer-eventsを使って重なり順(z-index)が下の要素をクリック可能にする</title>
		<link>https://web-creators-hub.com/web-cording/pointer-events/</link>
		<pubDate>Sun, 21 Apr 2019 09:25:59 +0000</pubDate>
		<dc:creator><![CDATA[taizo]]></dc:creator>
				<category><![CDATA[webコーディング]]></category>

		<guid isPermaLink="false">https://web-creators-hub.com/?p=207</guid>
		<description><![CDATA[pointer-events: none; 「pointer-events: none;」はマウスイベントを無効するものですが、要素が重なっ...]]></description>
				<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-213" src="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/pointer-events.png" alt="" width="700" height="350" srcset="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/pointer-events.png 700w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/pointer-events-300x150.png 300w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/pointer-events-320x160.png 320w" sizes="(max-width: 700px) 100vw, 700px" /></p>
<h2>pointer-events: none;</h2>
<p>「pointer-events: none;」はマウスイベントを無効するものですが、要素が重なっている場合は背後にある要素にマウスイベントが発生します。z-indexの値を無視して背面要素を操作可能することができます。</p>
<p>以下のように背面の要素にリンクがある場合、z-indexの値が大きい要素にカーソルを合わしても背面要素のリンクをクリックすることができない。<br />
<img src="/image/pointer-events.gif" alt="" /></p>
<p><span class="bold">html</span></p>
<pre class="brush: xml; title: ; notranslate">

&lt;div class=&quot;Contents&quot;&gt;
  
&lt;div class=&quot;Contents__text&quot;&gt;
    ここをクリック
  &lt;/div&gt;

  
&lt;div class=&quot;Contents__img&quot;&gt;
    &lt;a href=&quot;sample.html&quot;&gt;&lt;img src=&quot;sample.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;
  &lt;/div&gt;

&lt;/div&gt;

</pre>
<p><span class="bold">css</span></p>
<pre class="brush: css; title: ; notranslate">
.Contents {
  position: relative;
}
.Contents__text {
  position: absolute;
  padding: 30px;
  background-color: #78b54a;
  z-index: 2;
}
.Contents__img {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}
</pre>
<p>上に重なっている要素に「pointer-events: none;」を追加するとz-indexの値を無効にしクリックできるようになる。</p>
<p><img src="/image/pointer-events2.gif" alt="" /></p>
<p><span class="bold">html</span></p>
<pre class="brush: xml; title: ; notranslate">

&lt;div class=&quot;Contents&quot;&gt;
  
&lt;div class=&quot;Contents__text&quot;&gt;
    ここをクリック
  &lt;/div&gt;

  
&lt;div class=&quot;Contents__img&quot;&gt;
    &lt;a href=&quot;sample.html&quot;&gt;&lt;img src=&quot;sample.jpg&quot; alt=&quot;&quot;&gt;&lt;/a&gt;
  &lt;/div&gt;

&lt;/div&gt;

</pre>
<p><span class="bold">css</span></p>
<pre class="brush: css; title: ; notranslate">
.Contents {
  position: relative;
}
.Contents__text {
  position: absolute;
  padding: 30px;
  background-color: #78b54a;
  z-index: 2;
  pointer-events: none; //ここに追加
}
.Contents__img {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}
</pre>
]]></content:encoded>
			</item>
		<item>
		<title>【一行のみ】CSSを使い画像を中央でトリミングしはみ出し切り取る</title>
		<link>https://web-creators-hub.com/web-cording/object-fit/</link>
		<pubDate>Sat, 20 Apr 2019 03:42:06 +0000</pubDate>
		<dc:creator><![CDATA[taizo]]></dc:creator>
				<category><![CDATA[webコーディング]]></category>

		<guid isPermaLink="false">https://web-creators-hub.com/?p=193</guid>
		<description><![CDATA[object-fit: cover 画像の横幅と縦幅を固定し動的に画像を出力したとき、縦横比が崩れてしまいます。これに対応する場合、意外と面...]]></description>
				<content:encoded><![CDATA[<p><img src="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/object-fit.png" alt="" width="700" height="350" class="alignnone size-full wp-image-204" srcset="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/object-fit.png 700w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/object-fit-300x150.png 300w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/object-fit-320x160.png 320w" sizes="(max-width: 700px) 100vw, 700px" /></p>
<h2>object-fit: cover</h2>
<p>画像の横幅と縦幅を固定し動的に画像を出力したとき、縦横比が崩れてしまいます。これに対応する場合、意外と面倒ですが、「object-fit」を使うと簡単に対応できます。</p>
<p><strong>縦横比の崩れ</strong></p>
<p>たとえば横幅を600pxと縦幅800pxに固定し比率の違う画像を表示すると以下のように画像の比率が崩れ違和感のある画像になります。</p>
<p><img class="alignnone size-full wp-image-194" src="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/objectfit.jpg" alt="" width="1200" height="804" srcset="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/objectfit.jpg 1200w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/objectfit-300x201.jpg 300w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/objectfit-768x515.jpg 768w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/objectfit-1024x686.jpg 1024w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/objectfit-320x214.jpg 320w" sizes="(max-width: 1200px) 100vw, 1200px" /></p>
<p>このような場合PhotoShopなどの画像ソフトを使って比率に合うようにトリミングするのですがCSSの「object-fit: cover」を使うことで以下のように自動で両サイドをカットしトリミングします。</p>
<p><img class="alignnone size-full wp-image-195" src="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/objectfit2.jpg" alt="" width="1200" height="805" srcset="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/objectfit2.jpg 1200w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/objectfit2-300x201.jpg 300w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/objectfit2-768x515.jpg 768w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/objectfit2-1024x687.jpg 1024w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/objectfit2-320x215.jpg 320w" sizes="(max-width: 1200px) 100vw, 1200px" /></p>
<p><img src="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/objectfit3.jpg" alt="" width="640" height="427" class="alignnone size-full wp-image-196" srcset="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/objectfit3.jpg 640w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/objectfit3-300x200.jpg 300w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/objectfit3-320x214.jpg 320w" sizes="(max-width: 640px) 100vw, 640px" /></p>
<pre class="brush: css; title: ; notranslate">
.imageWrapper{
  width:600px;
  height: 800px;
}
.imageWrapper img{
  width:100%;
  height:100%;
  object-fit: cover; //追加
}
</pre>
<h2>レスポンシブ時メイン画像など縦幅だけ固定しスマホ版表示</h2>
<p>レスポンシブ対応の時、メイン画像がスマホ版で小さくなってしまう場合縦幅はそのままに表示したいときなど「object-fit: cover」が活躍します。</p>
<p><img class="alignnone size-full wp-image-194" src="/image/objectfit.gif" alt="" width="600" /><br />
スマホでも画像が小さくならないように高さを指定。「object-fit: cover」を使えば横幅が変わっても画像の比率崩れがない。</p>
<pre class="brush: css; title: ; notranslate">
.imgContent {
  
  width: 1000px;
}

@media only screen and (max-width: 768px) 
{
  .imgContent {
    width: 100%;
  }
}
.imgContent__img{
    height: 600px;
    margin: 0;
}
@media only screen and (max-width: 768px) {
  .imgContent__img {
        width: 100%;
        height: 600px;
  }
}
.imgContent__img img {
      width: 100%;
      height: 100%;
      object-fit: cover;
}
</pre>
]]></content:encoded>
			</item>
		<item>
		<title>レスポンシブ対応のときなどflexboxを使って順序を入れ替える</title>
		<link>https://web-creators-hub.com/web-cording/row-reverse/</link>
		<pubDate>Fri, 19 Apr 2019 04:02:01 +0000</pubDate>
		<dc:creator><![CDATA[taizo]]></dc:creator>
				<category><![CDATA[webコーディング]]></category>

		<guid isPermaLink="false">https://web-creators-hub.com/?p=184</guid>
		<description><![CDATA[flex-flow: row-reverse レスポンシブ対応などで順序を逆転したいときがあります。 そのときはたった一行で逆転します。 d...]]></description>
				<content:encoded><![CDATA[<p><img src="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/css_not.png" alt="" width="700" height="350" class="alignnone size-full wp-image-191" srcset="https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/css_not.png 700w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/css_not-300x150.png 300w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2019/04/css_not-320x160.png 320w" sizes="(max-width: 700px) 100vw, 700px" /></p>
<h2>flex-flow: row-reverse</h2>
<p>レスポンシブ対応などで順序を逆転したいときがあります。<br />
そのときはたった一行で逆転します。</p>
<p>display:flex;を追加している下に以下のコードを入れるだけで対応できます。</p>
<pre class="brush: css; title: ; notranslate">
display:flex;

/* 以下のコードを追加し位置を逆転 */
flex-flow: row-reverse;

</pre>
]]></content:encoded>
			</item>
		<item>
		<title>一部だけ除外したい CSS の :not() の使用方法</title>
		<link>https://web-creators-hub.com/web-cording/not/</link>
		<pubDate>Mon, 13 Nov 2017 13:55:32 +0000</pubDate>
		<dc:creator><![CDATA[taizo]]></dc:creator>
				<category><![CDATA[webコーディング]]></category>

		<guid isPermaLink="false">https://web-creators-hub.com/?p=147</guid>
		<description><![CDATA[またに使うCSS の :not() の使い方をまとめました。 基本的な使い方 基本的な使い方はこのタグ以外適用したい場合に使います。カッコの...]]></description>
				<content:encoded><![CDATA[<p><img class="size-full wp-image-165 aligncenter" src="https://web-creators-hub.com/__wordpress/wp-content/uploads/2017/11/css_not.png" alt="" width="700" height="350" srcset="https://web-creators-hub.com/__wordpress/wp-content/uploads/2017/11/css_not.png 700w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2017/11/css_not-300x150.png 300w, https://web-creators-hub.com/__wordpress/wp-content/uploads/2017/11/css_not-320x160.png 320w" sizes="(max-width: 700px) 100vw, 700px" /></p>
<p>またに使うCSS の :not() の使い方をまとめました。</p>
<h2>基本的な使い方</h2>
<p>基本的な使い方はこのタグ以外適用したい場合に使います。カッコの中に除外したいタグを指定するだけで使用できます。CSS3が使えるようになり使う機会が増えてきました。</p>
<h2>指定タグを除外</h2>
<pre class="brush: css; title: ; notranslate">
/* Pタグ以外適用 */
:not(p) {
  color:#FFF;
}

/* divタグ以外適用 */
:not(div) {
  color:#FFF;
}

/* h1タグ以外適用 */
:not(h1) {
  color:#FFF;
}
</pre>
<h2>指定IDのみ除外</h2>
<pre class="brush: css; title: ; notranslate">
/* #id以外適用 */
:not(#id) {
  color:#FFF;
}
</pre>
<h2>指定クラスのみ除外</h2>
<pre class="brush: css; title: ; notranslate">
/* Pタグの.class以外適用 */
p:not(.class) {
  color:#FFF;
}
</pre>
<h2>指定擬似クラスのみ除外</h2>
<pre class="brush: css; title: ; notranslate">
/* 擬似クラスhover以外適用 */
a:not(:hover) {
  color:#FFF;
}

/* 擬似クラスfirst-child以外適用 */
div:not(:first-child) {
  color:#FFF;
}
</pre>
<h2>指定の属性セレクタのみ除外</h2>
<pre class="brush: css; title: ; notranslate">
/* href 属性以外適用 */
a:not([href]) {
  color:#FFF;
}
/* href 属性以外適用 */
a:not([href]) {
  color:#FFF;
}

/* href 属性example.comを含んでいるもの以外適用 */
a:not([href*=&quot;example.com&quot;]{
  color:#FFF;
}

/* type 属性textを含んでいるもの以外適用 */
:not([type=&quot;text&quot;]) {
  color:#FFF;
}
</pre>
<h2>指定の子要素のみ除外</h2>
<p>.contensクラスのh2のみ除外</p>
<pre class="brush: xml; title: ; notranslate">
&lt;div class=&quot;contents&quot;&gt;
   &lt;h2&gt;ここが除外&lt;/h2&gt;
   &lt;p&gt;ここは適用&lt;/p&gt;
   &lt;p&gt;ここは適用&lt;/p&gt;
&lt;/div&gt;
</pre>
<pre class="brush: css; title: ; notranslate">
.contents :not(h2) {
  color:#FFF;
}
</pre>
<h2>実際に使った例</h2>
<p>チェックボックス以外</p>
<pre class="brush: xml; title: ; notranslate">
&lt;form class=&quot;form&quot;&gt;
   &lt;dl&gt;
      &lt;dt&gt;テキスト&lt;/dt&gt;
      &lt;dd&gt;
         &lt;div&gt;
            &lt;input id=&quot;b&quot; name=&quot;b&quot; value=&quot;&quot; type=&quot;text&quot;&gt;
         &lt;/div&gt;
      &lt;/dd&gt;
   &lt;/dl&gt;
   &lt;dl&gt;
      &lt;dt&gt;チェック&lt;/dt&gt;
      &lt;dd&gt;
         &lt;div&gt;
            &lt;label&gt;
               &lt;input id=&quot;c&quot; name=&quot;c&quot; value=&quot;1&quot; type=&quot;checkbox&quot;&gt;こちらをチェック
               &lt;span&gt;&lt;/span&gt;
            &lt;/label&gt;
         &lt;/div&gt;
      &lt;/dd&gt;
   &lt;/dl&gt;
&lt;/form&gt;
</pre>
<pre class="brush: css; title: ; notranslate">
.form dd input:not([type=&quot;checkbox&quot;]){
	background: #fff;
	padding: 0 0 0 10px;
	width: 100%;
}
</pre>
]]></content:encoded>
			</item>
	</channel>
</rss>
