放大图像:悬停

时间:2015-06-23 05:24:36

标签: html css css3

我开始学习使用HTML和CSS。

我有一些想法,我知道这可以借助JavaScript来实现。 但是我想知道它是否只能用CSS。

这是我的形象:

<img id="picturegoeshere" src="picture.png" width="100" height="90">

这是CSS部分:

.picturegoeshere:hover
{
 transform:scale(2,2);
 transform-origin:0 0;
}

他们是一种点击图片,然后弹出的方法吗? “悬停”有效,但我想要'弹出'留下来。因为在此部分工作之后,但我想添加有关图像的信息(超链接或其他内容)。

我找到了.picturegoeshere:active,但只有在鼠标点击仍然停止时才会变大..

我相信很多人都提出了同样的问题,但我似乎无法找到他们的问题,我一定是在寻找错误的问题,因为我不知道CSS的术语,我猜?

3 个答案:

答案 0 :(得分:3)

不,不喜欢你在做......

如果您只想使用此css,请执行此操作... 如你所知,你可以使用焦点而不是点击它!对! (两者都是一样的)。 只需在屏幕上创建弹出菜单并隐藏它,然后像这样使用CSS

#image1:focus #popupmenu {

显示:初始;

}

你需要什么:::  1.首先在屏幕上显示图像。

  1. 使用position:fixed;

  2. 显示弹出菜单
  3. 然后隐藏您的菜单。

  4. 隐藏使用后

  5.   

    #image1:focus #popupmenu {display:initial; }

    1. 这会为您创建一个弹出菜单。

    2. 对关闭按钮和拇指更改使用相同的方法

答案 1 :(得分:1)

<a href="#openModal">
 <img src="http://www.cssscript.com/wp-content/themes/iconic-one/img/twitter.png" alt="Follow us on Twitter"></a>

 <div id="openModal" class="modalDialog">
  <div> 
  <a href="#close" title="Close" class="close">X</a>
        <h2>Modal Box</h2>
    <p>This is a sample modal box that can be created using the powers of CSS3.</p>
    <p>You could do a lot of things here like have a pop-up ad that shows when your website loads, or create a login/register form for users.</p>
 </div>

.modalDialog {
  position: fixed;
  font-family: Arial, Helvetica, sans-serif;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 99999;
  opacity:0;
  -webkit-transition: opacity 400ms ease-in;
  -moz-transition: opacity 400ms ease-in;
  transition: opacity 400ms ease-in;
  pointer-events: none;
 }

 .modalDialog:target {
   opacity:1;
  pointer-events: auto;
 }

 .modalDialog > div {
  width: 400px;
  position: relative;
  margin: 10% auto;
  padding: 5px 20px 13px 20px;
  border-radius: 10px;
  background: #fff;
  background: -moz-linear-gradient(#fff, #999);
  background: -webkit-linear-gradient(#fff, #999);
  background: -o-linear-gradient(#fff, #999);
 }

 .close {
  background: #606061;
  color: #FFFFFF;
  line-height: 25px;
  position: absolute;
  right: -12px;
  text-align: center;
  top: -10px;
  width: 24px;
  text-decoration: none;
  font-weight: bold;
  -webkit-border-radius: 12px;
  -moz-border-radius: 12px;
  border-radius: 12px;
  -moz-box-shadow: 1px 1px 3px #000;
  -webkit-box-shadow: 1px 1px 3px #000;
  box-shadow: 1px 1px 3px #000;
  }

  .close:hover {
    background: #00d9ff;
   }

答案 2 :(得分:1)

我认为你正在寻找这个:

&#13;
&#13;
body {
  font-family: Arial, sans-serif;
  background: url(4.jpg);
  background-size: cover;
}

h1 {
  text-align: center;
  font-family: Tahoma, Arial, sans-serif;
  color: orange;
  margin: 100px 0;
}

.box {
  width: 20%;
  margin: 0 auto;
  background: rgba(255,255,255,0.2);
  padding: 35px;
  border: 2px solid #fff;
  border-radius: 20px/50px;
  background-clip: padding-box;
  text-align: center;
}

.button {
  font-size: 1em;
  padding: 10px;
  color: #fff;
  border: 2px solid orange;
  border-radius: 20px/50px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s ease-out;
     background: orange;
}
.button:hover {
  background: orange;
}

.overlay {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  transition: opacity 500ms;
  visibility: hidden;
  opacity: 0;
}
.overlay:target {
  visibility: visible;
  opacity: 1;
}

.popup {
  margin: 70px auto;
  padding: 20px;
  background: #fff;
  border-radius: 5px;
  width: 30%;
  position: relative;
  transition: all 5s ease-in-out;
}

.popup h2 {
  margin-top: 0;
  color: #333;
  font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
  position: absolute;
  top: 20px;
  right: 30px;
  transition: all 200ms;
  font-size: 30px;
  font-weight: bold;
  text-decoration: none;
  color: #333;
}
.popup .close:hover {
  color: orange;
}
.popup .content {
  max-height: 30%;
  overflow: auto;
}
&#13;
<h1>Popup/Modal Windows without JavaScript</h1>
<div class="box">
	<a class="button" href="#popup1">Let me Pop up</a>
</div>

<div id="popup1" class="overlay">
	<div class="popup">
		<h2>Here i am</h2>
		<a class="close" href="#">×</a>
		<div class="content">
			Thank to pop me out of that button, but now i'm done so you can close this window.
		</div>
	</div>
</div>
&#13;
&#13;
&#13;

检查此网站: -

http://www.sevensignature.com/blog/code/pure-css-popup-without-javascript

http://meyerweb.com/eric/css/edge/popups/demo.html

相关问题