gpt4 book ai didi

css - 保持三 Angular 形边缘可见,其余部分隐藏

转载 作者:太空宇宙 更新时间:2023-11-04 11:46:13 27 4
gpt4 key购买 nike

我正在制作一个动画,当我们将鼠标悬停在一个三 Angular 形上时,三 Angular 形会移动并显示之前隐藏的内容。

What i´ve done

它工作正常,但没有响应,在我的电脑上它很好但是当我调整我的窗口大小时三 Angular 形出现在屏幕中间或随机位置,我如何保持位置,以便只有黑色三 Angular 形可见?

我的代码,以防万一:

body{
height:100%;
background-color: grey;
}

/* AVISO :: Começo da animação trianglo lado esquerdo :: AVISO */

#container {
top:35%;
margin-left: -19.5%;
background-color: transperent;
width:355px;
}

.pencil-body {
background-color: red;
display: inline-block;
padding: 75px;
width: 100px;
}

.pencil-tip {
width: 0;
height: 0;
border-top: 75px solid transparent;
border-left: 100px solid black;
border-bottom: 75px solid transparent;
display: inline-block;
}

#container:hover {
transform: translate(200px,0);
-webkit-transform: translate(200px,0); /** Chrome & Safari **/
}

/* AVISO :: Fim da animação trianglo lado esquerdo :: AVISO */

/* AVISO :: Começo da animação trianglo lado direito :: AVISO */

#container2 {
float:right;
margin-left:92.5%;
top:35%;
width:355px;
}

.pencil-body2 {
float:right;
background-color: red;
display: inline-block;
padding: 75px;
width: 100px;
}

.pencil-tip2{
width: 0;
height: 0;
border-top: 75px solid transparent;
border-right: 100px solid black;
border-bottom: 75px solid transparent;
}

#container2:hover {
transform: translate(-200px,0);
-webkit-transform: translate(0px,200); /** Chrome & Safari **/
}

/* AVISO :: Fim da animação trianglo lado direito :: AVISO */

.animation {
position: absolute;
transition: all 2s ease-in-out;
-webkit-transition: all 2s ease-in-out; /** Chrome & Safari **/
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> Teste1 </title>
<link href="styles.css" rel="stylesheet" type="text/css">
</head>

<body style="overflow: hidden;">

<div id="container" class="animation">

<div class="pencil-body"></div>
<div class="pencil-tip"></div>

</div>

<div id="container2" class="animation">

<div class="pencil-body2"></div>
<div class="pencil-tip2"></div>

</div>

</body>



</body>
</html>

最佳答案

你应该使用

left: -255px;

right: -255px;

而不是使用边距。

例如:

#container {
left: -255px;
}

#container2 {
right: -255px;
}

此外,如果可以的话,您应该使用 html5。这是基本设置

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8>
<title>title</title>
</head>
<body>
...
</body>
</html>

例子: http://jsbin.com/lihuzoxube/edit?html,css,output

关于css - 保持三 Angular 形边缘可见,其余部分隐藏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30977305/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com