-14

我正在制作一个网站,但我只想显示一个通知(仅在会员打开网站时显示一次)。此通知必须显示在 html 主页的正上方(因为主页可能会因会员而异)。我想用'opacity'在首页上方做一个淡入淡出的页面(这样会员也可以在通知的四个侧面旁边看到主页),我不能使用“alert”,因为通知包含图片、代码和一些额外的功能诸如正面颜色之类的代码。到目前为止,我发现“不透明度”使用上面的图片,但我如何在我网站的 html 主页上方使用“不透明度”?

<html>
<head>
<style>
div.bacgro
  {
  width:500px;
  height:250px;
  background:url of a jpg file;
  border:2px solid black;
  }
div.trabox
  {
  width:400px;
  height:180px;
  margin:30px 50px;
  background-color:#ffffff;
  border:1px solid black;
  opacity:0.6;
  filter:alpha(opacity=60); /* For IE8 and earlier */
  }
div.trabox p
  {
  margin:30px 40px;
  font-weight:bold;
  color:#000000;
  }
</style>
</head>

<body>

<div class="bacgro">
<div class="trabox">
<p>This is some text that is placed in the transparent box. It may contain some code and small profile image also ...
</p>
</div>
</div>

</body>
</html>

但最重要的是我想将background:url of a jpg file;in 替换为background:"url of my site's homepage";

4

3 回答 3

1

我不太确定你在问什么,但如果你想要一个警报或小消息,你有几个选择。

警报框

<script>
function myFunction() 
{
alert("I am an alert box!");
}
</script>

或者你可以试试这个

 <script language="javascript" type="text/javascript">  
 <!--
 function popitup(url) {
newwindow=window.open(url,'name','height=200,width=150');
if (window.focus) {newwindow.focus()}
return false;
 }

 // -->
 </script>

这是弹出消息的两种常用方法。

于 2013-12-20T15:37:55.867 回答
1

如果您的通知只是一张图片,在您的 css 中您可以执行以下操作:

.yourNoticeId
{
  opacity:0.4; /* scale 0-1 */
  filter:alpha(opacity=40); /* For IE8 and earlier */
}

如果它是 div 的一部分

.yourdiv
{
   /*r = red color g = green color b = blue color and a = opacity 0-1 scale */
   background: rgba(200, 54, 54, 0.5); 
}
于 2013-12-20T15:38:12.353 回答
1

使用不透明度的事情是,您的元素或组件将始终存在并占用它需要或允许拥有的空间。因此,为了更好的目的,您可以同时使用 display 和 opacity ,并且在您的淡入淡出动画之后,将 display 写入none

于 2021-08-04T17:56:54.980 回答