我试着用css3从零开始制作一个图片库.这是我到目前为止所拥有的。
这是我的三大问题专辑。
我在safari和chrome中测试了它,这些问题在这两种浏览器中都存在(3号除外)。下面是我正在进行的代码:
body {
background: #eee;
font: 400 14px/20px'PT Serif', serif;
color: #2b2e2e;
margin: 0;
padding: 0;
}
article {
width: 80%;
margin: 0 auto;
}
nav,
img,
header,
figure {
display: inline-block;
margin: 0;
padding: 0;
}
header {
width: 30%;
margin-right: 3%;
}
nav ul li {
font: 12px/16px normal'Raleway', sans-serif;
letter-spacing: 2px;
display: block;
margin: 2px 0;
vertical-align: top;
}
date {
border-bottom: 2px solid #000;
border-top: 2px solid #000;
display: block;
font-size: 12px;
margin: 0 auto;
text-align: center;
text-transform: uppercase;
}
h1 {
font: 700 36px/40px'PT Sans Narrow', sans-serif;
text-transform: uppercase;
padding: 0 1em;
}
header {
background: #fff;
height: 80%;
margin-bottom: 3%;
}
p {
margin: 16px 0 20px 0;
}
ul,
ol {
margin-bottom: 20px;
}
div {
margin: 0;
padding: 0;
display: inline-block;
}
img {
width: auto;
height: 200%;
margin: 0 auto;
}
figure {
vertical-align: top;
position: relative;
overflow: hidden;
cursor: pointer;
width: 30%;
height: 30%;
margin: 0 3% 3% 0;
}
figcaption {
background: #fff;
display: block;
position: absolute;
bottom: 0;
left: 0;
width: 100%;
padding: .25em 1em;
}
figure:first-of-type {
width: 63%;
height: 80%;
margin-bottom: 3%;
}
figure:focus {
width: 80%;
height: 80%;
transition: all 1s ease-out .5ms;
-webkit-transition: all 1s ease-out .5ms;
-moz-transition: all 1s ease-out .5ms;
-o-transition: all 1s ease-out .5ms;
position: absolute;
top: 0;
left: 10%;
text-align: center;
z-index: 1000;
outline: none;
}<html>
<head>
<title>Sample Article</title>
<link href='http://fonts.googleapis.com/css?family=Raleway:600' rel='stylesheet' type='text/css'>
</head>
<body>
<article>
<header>
<nav>
<ul>
<li><a href="">Top</a>
<ul>
<li>Sub</li>
</ul>
</li>
<li><a href="">Menu</a>
<ul>
<li>Links</li>
<li>Go</li>
<li>Here</li>
</ul>
</li>
<li><a href="">Links</a>
<ul>
<li>And</li>
<li>Here</li>
</ul>
</li>
</ul>
</nav>
<h1>Example Article Title</h1>
</header>
<figure tabindex=1>
<img src="http://i.imgur.com/JdRTuQB.jpg" />
<figcaption>Text goes here. Obviously there'll be more. Like this.</figcaption>
</figure>
<figure tabindex=2>
<img src="http://i.imgur.com/4PkhPlq.jpg" />
<figcaption>Text goes here too</figcaption>
</figure>
<figure tabindex=3>
<img src="http://i.imgur.com/kTcyEOe.jpg" />
<figcaption>Some more captions</figcaption>
</figure>
<figure tabindex=4>
<img src="http://i.imgur.com/mIeUOYX.jpg" />
<figcaption>Almost done! Hehehe</figcaption>
</figure>
</article>
</body>
</html>
http://codepen.io/anon/pen/EadOyL?editors=110
发布于 2015-03-13 10:59:18
问题
inline-block而不添加浮点方向时,似乎会出现这种情况。
Fix:float:left;
:focus现在并不是真正的点击,对吗?聚焦元素是选择当前元素的内容。在选择它的方法上,点击一下。现在,由于您在元素和位置绝对值上使用位置相对,元素将不会占用任何空间,因为这就是位置绝对值所做的。
;博士:.
我添加了一个fig-container类的div,该类相对定位,具有与图形相同的高度和宽度。并在:focus上添加了一个不同的效果,我将绝对定位元素(图)设置为顶部50%,左上角50%,使图形的左上角都位于视图的中心。并增加了一个转换转换为-50% x和-50% y transform: transition(-50%, -50%);,这将把它移动到自己的中心。换句话说:把这一要素放在中心。
我要你为我编码:
好的,这是码页
https://stackoverflow.com/questions/29027774
复制相似问题