WEBページの部品作り

前書き

主立った部分の一覧を作っておくと、コーディングやシステムへの組込みがしやすい。
文字数が増えた場合を想定して作る。
余白等の調整にemを使えば、フォントサイズが変わってもデザインは崩れない。

目次

  1. 見出し
  2. 文章
  3. 余白
  4. 箇条書き
  5. 表(テーブル)
  6. その他

見出し

H1

h1{
  position: relative;
  font-weight: bold;
  line-height: 1.5;
  padding: 0 0 0.25em;
}
h1::after {
  content: "";
  position: absolute;
  bottom: 0;
  right: 0;
  left: 0;
  height: 3px;
  background-image: linear-gradient(to right, #e7d4e3 0%, #a675a5 100%);
}
H2

h2{
  color: #fff;
  font-weight: bold;
  line-height: 1.5;
  background: #a675a5;
  padding: 0.25em 0.75em;
  border-radius: 3px;
}
H3

h3{
  font-weight: bold;
  line-height: 1.5;
  padding: 0 0 0 0.75em;
  border-style: solid;
  border-width: 0 0 0px 5px;
  border-color: #e7d4e3 #a675a5;
}
H4

h4{
  display:flex;
  font-weight: bold;
  line-height: 1.5;
}
h4::before,
h4::after {
  flex-shrink: 0;
  content:'';
  width: 0.4em;
  border-style: solid;
  border-color: #a675a5;
}
h4::before {
  margin: 0 1em 0 0;
  border-width: 1px 0 1px 1px;
}
h4::after {
  margin: 0 0 0 1em;
  border-width: 1px 1px 1px 0;
}
H5

h5{
  position: relative;
  font-weight: bold;
  line-height: 1.5;
  padding: 0 0 0 1.7em;
}
h5::after {
  content: "";
  position: absolute;
  top: 0.25em;
  left: 0;
  width: 1em;
  height: 1em;
  background: repeating-linear-gradient(-45deg, #a675a5 0, #a675a5 4px, rgba(255,255,255,0) 4px, rgba(255,255,255,0) 8px);
}
H6

h6{
  position: relative;
  font-weight: bold;
  line-height: 1.5;
  padding: 0 0 0 1.7em;
}
h6::before,
h6::after{
  content: "";
  position: absolute;
  border-radius: 3px;
}
h6::before{
  top: 0;
  left: 0;
  z-index: 2;
  width: 0.8em;
  height: 0.8em;
  background: #a675a5;
}
h6::after{
  top:0.4em;
  left: 0.25em;
  z-index: 1;
  width: 1em;
  height: 1em;
  background: #e7d4e3;
}

文章

リンク小さい太い強調


a{
  color: #a675a5;
  text-decoration: underline;
}
em{
  font-style: normal;
  font-weight: bold;
  background: linear-gradient(rgba(255,255,255,0) 60%,#e7d4e3 60%);
}

※注釈(1文字分を字下げ)


.indent{
  padding: 0 0 0 1em;
  text-indent: -1em;
}

引用文

引用元

blockquote{
  padding: 0.5em 1em;
  border-left: 5px #eee solid;
}

余白


@for $i from 0 through 5 {
  .mgt#{$i*5} {
    margin-top: $i*5px !important;
  }
}

@media print, screen and (min-width: 768px){
  @for $i from 0 through 5 {
    .mgt#{$i*5}-md {
      margin-top: $i*5px !important;
    }
  }
}

.mgt0 {margin-top: 0px  !important}
.mgt5 {margin-top: 5px  !important}
.mgt10{margin-top: 10px !important}
.mgt15{margin-top: 15px !important}
.mgt20{margin-top: 20px !important}
.mgt25{margin-top: 25px !important}

@media print, screen and (min-width: 768px){
  .mgt0-md {margin-top: 0px  !important}
  .mgt5-md {margin-top: 5px  !important}
  .mgt10-md{margin-top: 10px !important}
  .mgt15-md{margin-top: 15px !important}
  .mgt20-md{margin-top: 20px !important}
  .mgt25-md{margin-top: 25px !important}
}

箇条書き

  • 番号なし1
  • 番号なし2
  • 番号なし3

ul li{
  position: relative;
  line-height: 1.75;
  padding: 0 0 0 1.25em;
}
ul li::after{
  content: "";
  position: absolute;
  top:0.5em;
  left: 0;
  width: 0.75em;
  height: 0.75em;
  background: #a675a5;
  border-radius: 50%;
}
  1. 番号あり1
  2. 番号あり2
  3. 番号あり3

ol{
  counter-reset: item;
}
ol li{
  position: relative;
  padding: 0 0 0 1.25em;
}
ol li::after{
  counter-increment:item;
  content: counter(item)'.';
  position: absolute;
  top:0;
  left: 0;
  color: #a675a5;
  font-weight: bold;
}

表(テーブル)

項目1項目2項目3項目4項目5

.overflow-x{
  /* tableの親要素 */
  overflow-x: auto;
}
table{
  width: 200%;
}
td,th{
  vertical-align: middle;
  padding: 0.5em 1em;
  border-style: solid;
  border-color: #e7d4e3;
  border-width: 1px 0;
}
th{
  text-align: center;
  background: #e7d4e3;
}
@media print, screen and (min-width: 768px){
  table{
    width: 100%;
  }
}

その他

アイコン付リンク

アイコン付リンク1

.link-icon{
  position: relative;
  display: inline-block;
  vertical-align: top;
  line-height: 1.75;
  padding: 0 0 0 1.5em;
}
.link-icon::after{
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 1em;
  height: 1.75em;
  background: url(icon.svg) no-repeat center center;
  background-size: contain;
}

ボタン


.button01{
  display: block;
  width: 100%;
  position: relative;
  color: #68394c;
  font-weight: bold;
  text-align: center;
  background: linear-gradient(to bottom, #fff 0%, #dfccc2 100%);
  padding: 0.5em 1em;
  border: 1px solid #dfccc2;
  border-radius: 3px;
  cursor: pointer;
}
.button01::after{
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  border: 1px solid #fff;
  border-radius: inherit;
}

.button02{
  display: block;
  width: 100%;
  color: #68394c;
  font-weight: bold;
  text-align: center;
  background: linear-gradient(to bottom,#fff 0%,#fff 55%, #f3efe5 55%, #f3efe5 100%);
  padding: 0.5em 1em;
  border: 1px solid #dfccc2;
  border-radius: 3px;
  cursor: pointer;
}

関連記事

大きさの異なる要素を隙間なく配置する(HTML/CSS)

フォトギャラリーを作る(HTML/CSS/JS)

画面全体に表示するメニューを作る(HTML/CSS/JS)

開閉するボックスを作る(HTML/CSS/JS)

CSSを使って自動で番号を振る

先頭に戻る
ページの先頭に戻る