Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

103.CSS布局技巧 #103

Open
neptoo opened this issue Dec 12, 2019 · 0 comments
Open

103.CSS布局技巧 #103

neptoo opened this issue Dec 12, 2019 · 0 comments
Labels

Comments

@neptoo
Copy link
Owner

neptoo commented Dec 12, 2019

阅读原文

灵活运用CSS开发技巧

CSS布局技巧

rem自适应布局

移动端使用rem布局需要通过JS设置不同屏幕宽高比的font-size

/* 基于UI width=750px DPR=2的页面 */
html {
    font-size: calc(100vw / 7.5);
}
使用:nth-child()选择指定元素
.specified-scope {
  width: 300px;

  li {
    padding: 0 20px;
    height: 40px;
    line-height: 40px;
    color: #fff;

    &:nth-child(odd) {
      background-color: #f66;
    }

    &:nth-child(even) {
      background-color: #66f;
    }

    &:nth-child(n+6):nth-child(-n+10) {
      /*6-10行*/
      background-color: #3c9;
    }
  }
}
使用writing-mode排版竖文
.vertical-text {
	writing-mode: vertical-rl;
	h3 {
		padding-left: 20px;
		font-weight: bold;
		font-size: 18px;
		color: #f66;
	}
	p {
		line-height: 30px;
		color: #66f;
	}
}
使用text-align-last对齐两端文本
.justify-text {
	li {
		margin-top: 5px;
		padding: 0 20px;
		width: 100px;
		height: 40px;
		background-color: #f66;
		line-height: 40px;
    /* !! */
		text-align-last: justify;
		color: #fff;
		&:first-child {
			margin-top: 0;
		}
	}
}
@neptoo neptoo added the 🌈CSS label Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant