开发者

CSS Positioning - How can you fix components in place?

开发者 https://www.devze.com 2023-03-27 02:15 出处:网络
Example - http://appdist.me What I\'d like to do is have the keyboard SVG fixed to the bottom of the screen and take up half the screen height, with the Facebook logo always overlaying the \'Q\' key,

Example - http://appdist.me

What I'd like to do is have the keyboard SVG fixed to the bottom of the screen and take up half the screen height, with the Facebook logo always overlaying the 'Q' key, no matter how the window is resized.

I've been trying to do this for days. What am I doing wrong? Thanks.

Here's my HTML:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="tex开发者_Python百科t/html; charset=utf-8">
        <link href="style.css" rel="stylesheet" type="text/css">
        <title>CSS Layout Problem</title>
    </head>
    <body>
        <div id="svg">
            <embed src="keyboard-gray.svg" id="keyboard"
                         type="image/svg+xml"
                         pluginspage="http://www.adobe.com/svg/viewer/install/"/>
            <embed src="fb.svg" id="facebook"
                         type="image/svg+xml"
                         pluginspage="http://www.adobe.com/svg/viewer/install/"/>
            <embed src="frame.svg" id="frame"
                         type="image/svg+xml"
                         pluginspage="http://www.adobe.com/svg/viewer/install/"/>
        </div>
    </body>

Here is my CSS:

body{
    background-color: #333;
}

#svg{

} 

#facebook{
   position: fixed;
   width: 6%;
   height: 6%;
}

#frame{
   position: fixed;
   width: 100%;
   height: 47%;
   top: 2%;
   left: 0;
}

#keyboard{
   position: fixed;
   width: 100%;
   height: 50%;
   bottom: 2%;
   left: 0;
}


If you want to merge the images and make the SVG interactive, then you can use <a> tags in your xml (instead of <g>). Check out this IBM link for some ideas on how to achieve different types of interactivity.

Good luck - it looks like you have a fun project to play with.


Position the #facebook absolutely too and set the z-index so that it shows above the keyboard.

#facebook{
  position: absolute;
  height: 12%;
  bottom: Y%;
  right: X%;
  z-index: 99;
}

Change X and Y so that it's above the Q key.

0

精彩评论

暂无评论...
验证码 换一张
取 消