Skip to content

Instantly share code, notes, and snippets.

@machida
Created November 6, 2017 03:23
Show Gist options
  • Save machida/d004489247c5c84481a09706517d35b4 to your computer and use it in GitHub Desktop.
Save machida/d004489247c5c84481a09706517d35b4 to your computer and use it in GitHub Desktop.
flexを使った例
/** * Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/) * http://cssreset.com */html, body, div, span, applet, object, iframe,h1, h2, h3, h4, h5, h6, p, blockquote, pre,a, abbr, acronym, address, big, cite, code,del, dfn, em, img, ins, kbd, q, s, samp,small, strike, strong, sub, sup, tt, var,b, u, i, center,dl, dt, dd, ol, ul, li,fieldset, form, label, legend,table, caption, tbody, tfoot, thead, tr, th, td,article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary,time, mark, audio, video { margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline;}/* HTML5 display-role reset for older browsers */article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block;}body { line-height: 1;}ol, ul { list-style: none;}blockquote, q { quotes: none;}blockquote:before, blockquote:after,q:before, q:after { content: ''; content: none;}table { border-collapse: collapse; border-spacing: 0;}
/* formのときに青い線を出さなくする 外したり付けたりしてどうなるか見てみよう */
input,
textarea,
select {
-webkit-tap-highlight-color: transparent;
outline: none;
}
/* ここにCSSを書いてデザインを入れよう */
body {
color: #444;
background-color: #aaa;
}
.container {
width: 980px;
margin-left: auto;
margin-right: auto;
background-color: #666;
box-shadow: rgba(0, 0, 0, .4) 0 0 8px;
overflow: hidden;
}
.header {
background-color: #999;
color: #444;
}
.header__title {
font-size: 42px;
font-weight: bold;
line-height: 1.4;
text-align: center;
padding-top: 40px;
padding-bottom: 40px;
text-shadow: rgba(255, 255, 255, .4) 0 1px 0;
}
.global-nav{
background-color: #ccc;
box-shadow: rgba(0, 0, 0, .4) 0 1px 1px;
position: relative;
}
.global-nav__items {
display: flex;
}
.global-nav__item {
display: block;
flex: 0 0 20%;
}
.global-nav__link {
text-decoration: none;
display: block;
font-size: 16px;
font-weight: bold;
line-height: 64px;
text-align: center;
color: #444;
text-shadow: rgba(255, 255, 255, .6) 0 1px 0;
background: linear-gradient(to bottom, #ddd 0%, #ccc 100%);
}
.global-nav__link:hover,
.global-nav__item:nth-child(even) .global-nav__link:hover {
background-color: #eee;
}
.global-nav__item:nth-child(even) .global-nav__link {
background-color: #bbb;
background: linear-gradient(to bottom, #bbb 0%, #aaa 100%);
}
.bread-crumbs {
padding-left: 16px;
padding-right: 16px;
background-image: linear-gradient(to bottom, #666666 0%, #555555 100%);
}
.bread-crumbs__items {
display: flex;
}
.bread-crumbs__item {
display: block;
position: relative;
padding-right: 24px;
}
.bread-crumbs__item:before {
content: ">";
font-size: 13px;
width: 24px;
line-height: 32px;
color: #aaa;
text-align: center;
position: absolute;
right: 0;
top: 0;
}
.bread-crumbs__item.is-current {
padding-right: 0;
}
.bread-crumbs__item.is-current:before {
content: none;
}
.bread-crumbs__link {
color: #fff;
font-size: 13px;
text-decoration: none;
line-height: 32px;
}
.top-ads {
background-color: #ccc;
padding: 16px 8px;
}
.top-ads__items {
display: flex;
justify-content: space-around;
}
.top-ads__item {
display: block;
flex: 0 0 305px;
}
.top-ads__image {
width: 100%;
height: auto;
}
.body {
display: flex;
flex-direction: row-reverse;
}
.main {
flex: 0 0 66%;
box-sizing: border-box;
background-color: #ddd;
}
.main-header {
background-color: #eee;
padding: 16px;
position: relative;
box-shadow: rgba(0, 0, 0, .3) 0 1px 1px;
overflow: hidden;
}
.main-header:before {
content: "";
display: block;
background-color: #aaa;
width: 44px;
height: 44px;
position: absolute;
right: -12px;
top: -12px;
box-shadow: rgba(0, 0, 0, .6) 0 1px 1px;
}
.main-header:after {
content: "";
display: block;
background-color: #ccc;
width: 44px;
height: 44px;
position: absolute;
right: -22px;
top: -22px;
transform: rotate(-45deg);
}
.main-header__title {
font-size: 36px;
line-height: 1.4;
font-weight: bold;
padding-left: 46px;
position: relative;
}
.main-header__title:before,
.main-header__title:after {
content: "";
display: block;
width: 12px;
height: 12px;
position: absolute;
border-right: 12px #444 solid;
}
.main-header__title:before {
left: 0;
top: 14px;
background-color: #999;
border-right-color: #444;
}
.main-header__title:after {
left: 0;
top: 26px;
background-color: #444;
border-right-color: #999;
}
.article {
padding: 16px;
}
.article__title {
font-size: 28px;
line-height: 1.4;
font-weight: bold;
margin-bottom: 16px;
padding-left: 24px;
position: relative;
}
.article__title:before {
content: "";
display: block;
width: 12px;
height: 20px;
position: absolute;
background-color: #999;
border-bottom: 20px #444 solid;
left: 0;
top: 0;
}
.article__sub-title {
font-size: 24px;
line-height: 1.4;
font-weight: bold;
margin-bottom: 16px;
position: relative;
padding-left: 24px;
}
.article__paragraph + .article__sub-title {
margin-top: 24px;
}
.article__sub-title:before,
.article__sub-title:after {
content: "";
display: block;
position: absolute;
}
.article__sub-title:before {
width: 4px;
height: 16px;
background-color: #444;
left: 0;
top: 9px;
}
.article__sub-title:after {
width: 0;
height: 0;
border-style: solid;
border-width: 8px 12px;
border-color: transparent;
border-left-color: #444;
left: 6px;
top: 9px;
}
.article__sub-sub-title {
font-size: 18px;
line-height: 1.4;
font-weight: bold;
margin-bottom: 16px;
position: relative;
padding-left: 24px;
}
.article__sub-sub-title:before,
.article__sub-sub-title:after {
content: "";
display: block;
position: absolute;
width: 12px;
height: 12px;
border-radius: 50%;
}
.article__sub-sub-title:before {
left: 0;
top: 6px;
background-color: #444;
}
.article__sub-sub-title:after {
left: 8px;
top: 6px;
background-color: #999;
}
.article__paragraph,
.article__blockquote-paragraph {
font-size: 16px;
line-height: 1.8;
margin-bottom: 16px;
}
.article__link {
color: royalblue;
}
.article__strong {
font-weight: bold;
color: #000;
}
.article__blockquote {
border-left: solid 6px #999;
padding-top: 24px;
padding-left: 24px;
position: relative;
margin-top: 40px;
margin-left: 8px;
margin-bottom: 32px;
}
.article__blockquote:before {
position: absolute;
left: -27px;
top: -22px;
content: '"';
font-size: 68px;
font-family: serif;
color: #eee;
text-align: center;
line-height: 84px;
background-color: #999;
width: 48px;
height: 48px;
border-radius: 50%;
}
.article__unorder-list,
.article__order-list {
margin-bottom: 16px;
margin-left: 24px;
list-style-position: outside;
}
.article__unorder-list {
list-style: disc;
}
.article__order-list {
list-style: decimal;
}
.article__order-list-item,
.article__unorder-list-item {
line-height: 1.6;
margin-bottom: 8px;
}
.article__image {
max-width: 100%;
height: auto;
margin-left: auto;
margin-right: auto;
margin-bottom: 24px;
}
.article__paragraph + .article__image {
margin-top: 8px;
}
.aside {
flex: 0 0 34%;
background-color: #666;
padding: 16px;
box-sizing: border-box;
}
.aside-ads {
margin-bottom: 24px;
}
.aside-ads__item {
margin-bottom: 8px;
}
.aside-ads__item:last-child {
margin-bottom: 0;
}
.aside-ads__image {
width: 100%;
height: auto;
}
.local-nav__item:first-child .local-nav__link {
border-radius: 4px 4px 0 0;
}
.local-nav__item:last-child .local-nav__link {
border-radius: 0 0 4px 4px;
}
.local-nav__link {
display: block;
padding: 0 16px;
font-size: 16px;
line-height: 42px;
text-decoration: none;
background-color: #999;
margin-bottom: 2px;
color: #fff;
}
.local-nav__link:hover {
background-color: #ccc;
}
.local-nav__link.is-current {
background-color: #777;
cursor: default;
}
.footer {
background-color: #444;
padding: 24px 16px;
display: flex;
flex-wrap: wrap;
}
.footer-nav {
flex: 0 0 50%;
display: flex;
}
.footer-nav__items {
flex: 0 0 33.33%;
}
.footer-nav__item {
line-height: 1.6;
margin-bottom: 6px;
font-size: 13px;
position: relative;
padding-left: 12px;
}
.footer-nav__item:after {
content: ">";
position: absolute;
left: 0;
top: 0;
color: #ccc;
}
.footer-nav__link {
color: #fff;
text-decoration: none;
}
.about-author {
flex: 0 0 50%;
background-color: #ccc;
margin-bottom: 32px;
box-sizing: border-box;
padding: 16px;
border-radius: 4px;
box-shadow: rgba(0, 0, 0, .5) 0 1px 1px inset, rgba(255, 255, 255, .3) 0 1px 1px;
}
.about-author__title {
font-size: 14px;
font-weight: bold;
line-height: 1.4;
margin-bottom: 16px;
}
.about-author__image {
width: 88px;
height: 88px;
border-radius: 50%;
float: left;
}
.about-author__descriptions {
padding-left: 104px;
}
.about-author__term {
display: block;
width: 60px;
position: absolute;
font-size: 14px;
line-height: 1.6;
text-align: right;
}
.about-author__description {
display: block;
padding-left: 72px;
margin-bottom: 8px;
font-size: 14px;
line-height: 1.6;
}
.footer-copyright {
flex: 0 0 100%;
display: block;
text-align: center;
font-size: 14px;
color: #fff;
}
.form {
background-color: #fff;
padding: 24px;
}
.form__title {
font-size: 24px;
line-height: 26px;
font-weight: bold;
margin-bottom: 24px;
position: relative;
padding-left: 52px;
overflow: hidden;
}
.form__title:before {
content: "";
display: block;
width: 36px;
height: 22px;
border: #444 solid 2px;
position: absolute;
left: 0;
top: 0;
}
.form__title:after {
content: "";
display: block;
width: 36px;
height: 36px;
border: #444 solid 2px;
position: absolute;
left: 0;
top: -28px;
transform: rotate(-45deg);
}
.form-item {
margin-bottom: 24px;
position: relative;
padding-left: 200px;
}
.form-item__label {
font-size: 14px;
font-weight: bold;
text-align: right;
width: 176px;
display: block;
position: absolute;
left: 0;
top: 0;
padding-top: 8px;
}
.form-item__text-input {
display: block;
width: 100%;
padding: 8px;
box-sizing: border-box;
border: solid 1px #ccc;
border-radius: 4px;
}
.form-item__textarea {
display: block;
width: 100%;
height: 320px;
padding: 8px;
box-sizing: border-box;
border: solid 1px #ccc;
border-radius: 4px;
}
.form-item__inline-items {
font-size: 0;
}
.form-item__inline-item {
display: inline-block;
margin-right: 16px;
}
.form-item__radio {
border: #ccc solid 1px;
padding: 12px;
font-size: 14px;
border-radius: 4px;
cursor: pointer;
display: block;
background-color: #eee;
}
.form-item__radio:hover {
background-color: #ddd;
box-shadow: rgba(0, 0, 0, .6) 0 1px 1px;
}
.form-item__radio-input {
margin: 0 8px 0 0;
}
.form-item__checkbox {
border: #ccc solid 1px;
padding: 12px;
font-size: 14px;
border-radius: 4px;
cursor: pointer;
display: block;
background-color: #ddd;
}
.form-item__checkbox:hover {
background-color: #ccc;
box-shadow: rgba(0, 0, 0, .6) 0 1px 1px;
}
.form-item__checkbox-input {
margin: 0 8px 0 0;
}
.form-item__select-pull-down {
width: 100%;
border: #ccc solid 1px;
background-color: #eee;
padding: 4px;
font-size: 14px;
box-shadow: rgba(0, 0, 0, .2) 0 1px 0 inset;
}
.form-item__select-list {
width: 100%;
border: #ccc solid 1px;
background-color: #eee;
font-size: 14px;
box-shadow: rgba(0, 0, 0, .2) 0 1px 0 inset;
overflow: hidden;
}
.form-item__select-list-option {
display: block;
cursor: pointer;
border-bottom: #ccc solid 1px;
padding: 8px;
}
.form-item__select-list-option:last-child {
border-bottom: none;
}
.form-item__file-contaner {
position: relative;
height: 32px;
}
.form-item__file {
height: 32px;
width: 100%;
cursor: pointer;
background-color: #eee;
border: #ccc solid 1px;
border-radius: 4px;
padding: 6px;
box-sizing: border-box;
box-shadow: rgba(0, 0, 0, .2) 0 1px 0 inset;
}
.form-item__actions-items {
text-align: center;
font-size: 0;
}
.form-item__actions-item {
display: inline-block;
padding-left: 8px;
padding-right: 8px;
width: 50%;
box-sizing: border-box;
}
.form-item__action {
display: block;
width: 100%;
border: #aaa solid 1px;
border-radius: 4px;
cursor: pointer;
height: 38px;
font-size: 14px;
}
.form-item__action.is-submit {
background-color: #444;
color: #fff;
border-color: #222;
box-shadow: rgba(0, 0, 0, .1) 0 1px 1px, rgba(255, 255, 255, .2) 0 1px 0 inset;
text-shadow: rgba(0, 0, 0, .4) 0 -1px 0;
}
.form-item__action.is-reset {
background-color: #ccc;
color: #444;
border-color: #aaa;
box-shadow: rgba(0, 0, 0, .1) 0 1px 1px, rgba(255, 255, 255, .6) 0 1px 0 inset;
text-shadow: rgba(255, 255, 255, .8) 0 1px 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment