着陆页帆布/徽标覆盖

问题描述 投票:1回答:1

我在文件夹中有一个徽标,我需要覆盖矩阵画布/背景。底部代码段是带有位置的Logo png文件。它似乎没有出现。我添加了带有边框为0的logo.png,但它在顶部留下了一个黑色的空白块。我需要图像与页面中心的矩阵代码重叠。

提前致谢。

P.S。:如果您不打算为我的logo.png文件提出建议,请不要编辑我的代码。我已经看过一次尝试,它改变了我想要的结果。

<!DOCTYPE html>
<html>
    <head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1" /> 
		<title>CybernetiX Corp</title>
        <style>

            /*basic reset */
            *{
                margin: 0;
                padding: 0;
            }
            
            /* Page settings */
            html {
                width: 100%;
                height: 100%;
                background: radial-gradient(circle, #fff 0%, #aaa 100%) no-repeat;
                overflow-x: hidden;
                overflow-y: hidden;
            }
            body {
                text-align: center;
                display: table;
                background: black;
                width: 100%;
                height: 100%;
                overflow-x: hidden;
                overflow-y: hidden;
            }

            canvas {display:block;}
            
            #author {
                position: absolute;
                bottom: 10px;
                left: 10px;
                color : #0F0;
                z-index : 1;
                box-sizing: border-box;
                vertical-align: middle;
            }
        
            span {
                font-family: monospace;
                font-size: 1.5em;
            }
            span:after {
                content:"CybernetiX-S3C";
                opacity: 0;
                animation: cursor 1s infinite;
            }
            @keyframes cursor {
                0% {
                    opacity: 0;
                }
                40% {
                    opacity: 0;
                }
                50% {
                    opacity: 1;
                }
                90% {
                    opacity: 1;
                }
                100% {
                    opacity: 0;
                }
            }
        
        </style>
    </head>
	<img src="img/LOGO.png"  alt="CybernetiX-Corp">

    <body>
    
        <canvas id="c"></canvas>
        <span id = "author">John Modica @ </span>
        

        
	<script>
        // geting canvas by id c
        var c = document.getElementById("c");
        var ctx = c.getContext("2d");

        //making the canvas full screen
        c.height = window.innerHeight;
        c.width = window.innerWidth;

        //chinese characters - taken from the unicode charset
        var matrix = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789@#$%^&*()*&^%";
        //converting the string into an array of single characters
        matrix = matrix.split("");

        var font_size = 10;
        var columns = c.width / font_size; //number of columns for the rain
        //an array of drops - one per column
        var drops = [];
        //x below is the x coordinate
        //1 = y co-ordinate of the drop(same for every drop initially)
        for(var x = 0; x < columns; x++)
            drops[x] = 1; 

        //drawing the characters
        function draw()
        {
            //Black BG for the canvas
            //translucent BG to show trail
            ctx.fillStyle = "rgba(0, 0, 0, 0.04)";
            ctx.fillRect(0, 0, c.width, c.height);

            ctx.fillStyle = "#0F0"; //green text
            ctx.font = font_size + "px arial";
            //looping over drops
            for( var i = 0; i < drops.length; i++ )
            {
                //a random chinese character to print
                var text = matrix[ Math.floor( Math.random() * matrix.length ) ];
                //x = i*font_size, y = value of drops[i]*font_size
                ctx.fillText(text, i * font_size, drops[i] * font_size);

                //sending the drop back to the top randomly after it has crossed the screen
                //adding a randomness to the reset to make the drops scattered on the Y axis
                if( drops[i] * font_size > c.height && Math.random() > 0.975 )
                    drops[i] = 0;

                //incrementing Y coordinate
                drops[i]++;
            }
        }

        setInterval( draw, 35 );

       </script>
	<p style-"text-align:center;"><img src="img/LOGO.png" alt="CybernetiX Corp"></p>
    </body>
	<body>
	</body>
</html>

	<img src="img/LOGO.png"  alt="CybernetiX-Corp">
javascript jquery html css
1个回答
0
投票

这是你如何做到的。主要变化是。

将以下HTML添加到正文中。图像周围的包装将是全屏的,因此您可以使用css flex在中间对齐图像。

<div class="img-wrapper"><img src="your-image"></div>

以下CSS将图像对齐在包装器的中间。

.img-wrapper {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.img-wrapper {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title>CybernetiX Corp</title>
  <style>
    /*basic reset */
    
    * {
      margin: 0;
      padding: 0;
    }
    /* Page settings */
    
    html {
      width: 100%;
      height: 100%;
      background: radial-gradient(circle, #fff 0%, #aaa 100%) no-repeat;
      overflow-x: hidden;
      overflow-y: hidden;
    }
    
    body {
      text-align: center;
      display: table;
      background: black;
      width: 100%;
      height: 100%;
      overflow-x: hidden;
      overflow-y: hidden;
    }
    
    canvas {
      display: block;
    }
    
    #author {
      position: absolute;
      bottom: 10px;
      left: 10px;
      color: #0F0;
      z-index: 1;
      box-sizing: border-box;
      vertical-align: middle;
    }
    
    span {
      font-family: monospace;
      font-size: 1.5em;
    }
    
    span:after {
      content: "CybernetiX-S3C";
      opacity: 0;
      animation: cursor 1s infinite;
    }
    
    @keyframes cursor {
      0% {
        opacity: 0;
      }
      40% {
        opacity: 0;
      }
      50% {
        opacity: 1;
      }
      90% {
        opacity: 1;
      }
      100% {
        opacity: 0;
      }
    }
  </style>
</head>

<body>

  <canvas id="c"></canvas>
  <span id="author">John Modica @ </span>



  <script>
    // geting canvas by id c
    var c = document.getElementById("c");
    var ctx = c.getContext("2d");

    //making the canvas full screen
    c.height = window.innerHeight;
    c.width = window.innerWidth;

    //chinese characters - taken from the unicode charset
    var matrix = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789@#$%^&*()*&^%";
    //converting the string into an array of single characters
    matrix = matrix.split("");

    var font_size = 10;
    var columns = c.width / font_size; //number of columns for the rain
    //an array of drops - one per column
    var drops = [];
    //x below is the x coordinate
    //1 = y co-ordinate of the drop(same for every drop initially)
    for (var x = 0; x < columns; x++)
      drops[x] = 1;

    //drawing the characters
    function draw() {
      //Black BG for the canvas
      //translucent BG to show trail
      ctx.fillStyle = "rgba(0, 0, 0, 0.04)";
      ctx.fillRect(0, 0, c.width, c.height);

      ctx.fillStyle = "#0F0"; //green text
      ctx.font = font_size + "px arial";
      //looping over drops
      for (var i = 0; i < drops.length; i++) {
        //a random chinese character to print
        var text = matrix[Math.floor(Math.random() * matrix.length)];
        //x = i*font_size, y = value of drops[i]*font_size
        ctx.fillText(text, i * font_size, drops[i] * font_size);

        //sending the drop back to the top randomly after it has crossed the screen
        //adding a randomness to the reset to make the drops scattered on the Y axis
        if (drops[i] * font_size > c.height && Math.random() > 0.975)
          drops[i] = 0;

        //incrementing Y coordinate
        drops[i]++;
      }
    }

    setInterval(draw, 35);
  </script>
  <div class="img-wrapper"><img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSYygrZgIU_1WjY1yAai9pp1hc56sm9bxMDa9aFOb5zyo5iA7mq" alt="CybernetiX Corp"></div>



</body>


</html>
© www.soinside.com 2019 - 2024. All rights reserved.