Dmt05
30.Май.2016 11:57:16
1
`body {
width: 280px;
min-height: 250px;
padding-top: 50px;
padding-left: 10px;
padding-right: 10px;
font-size: 12px;
font-family: “Arial”, sans-serif;
line-height: 1.2;
color: #7f8c8d ;
background: #ecf0f1 ;
}
.post-stats .icon {
width: 15px;
height: 15px;
}
.post{
width: 300px;
position: relative;
}
.post-date{
width: 55px;
height: 55px;
background: white;
font-size: 15px;
text-align: center;
vertical-align: middle;
font-weight: bold;
border-bottom: 5px solid #bdc3c7 ;
line-height: 55px;
}
.post-title{
color: #2980b9 ;
font-size: 20px;
position: absolute;
left: 75px
}
a {
color: #2980b9 ;
text-decoration: none;
}
.post-text{
background: white;
border-bottom: 5px solid #bdc3c7 ;
width: 165px;
height: 100px;
font-size: 12px;
position: absolute;
left: 75px;
top: 64px;
padding: 8px 15px
}
.post-author{
margin-left: 75px;
margin-top: -31px;
}
.post-stats{
font-size: 12px;
position: relative;
left: 75px;
display: inline-block;
padding-left: 20px;
top: 5px;
}
.icon{
position: absolute;
left: 0px
}
.icon-tags{
background: url(/assets/course14/post-challenge.png);
}
.icon-comments{
background: url(/assets/course14/post-challenge.png) 80% 0;
}
.post-type{
position: absolute;
top: 70px;
background: #7f8c8d url(/assets/course14/quotes.png) no-repeat 50% 50%;
width: 55px;
height: 55px;
border-bottom: 5px solid #bdc3c7
}`
.post-stats{
font-size: 12px;
position: relative;
left: 65px ;
display: inline-block;
padding-left: 30px ;
top: 5px;
}
.icon{
position: absolute;
left: 10px ;
}
.post-text{
background: white;
border-bottom: 5px solid #bdc3c7 ;
width: 165px;
/height: 100px; /
font-size: 12px;
position: absolute;
left: 75px;
top: 62px ;
padding: 10px 15px;
}
Не забывайте ставить точку с запятой в конце свойства.
Можете еще поработать над кратностью пяти и попытаться убрать отрицательный отступ.
Добрый вечер,
посмотрите пожалуйста и на мой код (97%). Хочу сделать на 100% с корректно составленным кодом.
(если сделать на 100% то заданные размеры не будут кратны 5 и 10. Есть сомнения по поводу использования - :nth-child(6).)
Код
.post div {
box-sizing: border-box;}
.post {
position: relative;}
.post .post-date {
background: #ffffff;
color: #7f8c8d;
width: 55px;
height: 60px;
border-bottom: 5px solid #bdc3c7;
position: absolute;
top: 0;
font-size: 15px;
font-weight: bold;
padding-top: 20px;
padding-left: 10px;}
.post .post-title {
margin-left: 75px;
margin-bottom: 5px;
font-size: 20px;
color: #2980b9;}
.post .post-type {
width: 55px;
height: 60px;
background: #7f8c8d url("/assets/course14/quotes.png") no-repeat 15px;
position: absolute;
top: 70px;
border-bottom: 5px solid #bdc3c7;
text-align: center;}
.post .post-author {
margin-left: 75px;
color: #7f8c8d;
margin-bottom: 5px;}
.post .post-author a {
text-decoration: none;
color: #2980b9;}
.post .post-stats {
display: inline-block;
margin-left: 75px;
padding-left: 20px;}
.post div:nth-child(6) {
margin-left: 10px;}
.post .post-stats a {
text-decoration: none;
color: #2980b9;}
.post .post-stats .icon {
width: 15px;
height: 15px;
background: url("/assets/course14/post-challenge.png") no-repeat;}
.post .post-stats .icon-tags {
position: absolute;
left: 75px;}
.post .post-stats .icon-comments {
background-position: -20px;
position: absolute;
top: 50px;
left: 225px;}
.post .post-text {
margin-left: 75px;
margin-right: 10px;
background: #ffffff;
padding: 10px 15px;
border-bottom: 5px solid #bdc3c7;}
Ineska
10.Ноябрь.2016 16:35:56
5
Вместо часто встречающегося внешнего отступа 75px лучше задать внутренний отступ единожды для родителя .post. Координаты для иконок в блоках .post-stats должны рассчитываться относительно блока .post-stats, а не от левого верхнего угла окна в браузере.
Координаты background-position у изображения с кавычками должны выравнивать его посередине. Дата по вертикали выравнивается с помощью line-height в пикселях.
:nth-child(6) конечно лишнее. Задаете отступ справа для .post-stats (для обоих).
С корректностью составления кода разобрался, благодаря вашим рекомендациям. Но осталось еще 2 процента (кавычки и иконка комментов).
.post div {
box-sizing: border-box;}
.post {
position: relative;
padding-left: 75px;
}
.post .post-date {
background: #ffffff;
color: #7f8c8d;
width: 55px;
height: 60px;
border-bottom: 5px solid #bdc3c7;
position: absolute;
top: 0;
left: 0;
font-size: 15px;
line-height: 55px;
font-weight: bold;
text-align: center;}
.post .post-title {
margin-bottom: 5px;
font-size: 20px;
color: #2980b9;}
.post .post-type {
width: 55px;
height: 60px;
background: #7f8c8d url("/assets/course14/quotes.png") no-repeat 15px 15px;
position: absolute;
top: 70px;
left: 0px;
border-bottom: 5px solid #bdc3c7;}
.post .post-author {
color: #7f8c8d;
margin-bottom: 5px;}
.post .post-author a {
text-decoration: none;
color: #2980b9;}
.post .post-stats {
display: inline-block;
padding-left: 20px;
position: relative;
margin-right: 10px;}
.post .post-stats a {
text-decoration: none;
color: #2980b9;}
.post .post-stats .icon {
width: 15px;
height: 15px;
background: url("/assets/course14/post-challenge.png") no-repeat;}
.post .post-stats .icon-tags {
position: absolute;
left: 0;}
.post .post-stats .icon-comments {
background-position: -20px;
position: absolute;
top: 0px;
left: 0px;}
.post .post-text {
margin-right: 10px;
background: #ffffff;
padding: 10px 15px;
border-bottom: 5px solid #bdc3c7;}
Ineska
10.Ноябрь.2016 17:15:05
7
Для кавычек background-position в процентах.
А что и иконкой комментов не так?
99%
в образце иконка комментов на 1пкс ниже
Ineska
10.Ноябрь.2016 17:31:38
9
Лучше все же задавать background-position как две координаты. Потому что если не задана вторая, то она считается такой же как первая.
А в данном случае мы двигаемся только по горизонтали по спрайту.
Поэтому так:
background-position: -20px 0;
1 лайк