鱼C论坛

 找回密码
 立即注册
楼主: 不二如是

[庖丁解牛] 0 0 0 5 - 优化内容区设置

[复制链接]
发表于 2017-7-10 17:12:34 | 显示全部楼层
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2017-8-1 21:46:36 | 显示全部楼层
懂了。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2017-8-6 19:37:35 | 显示全部楼层
为什么要设置区块宽度为100%,横向撑满屏幕呢?感觉没啥区别
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-8-24 19:32:59 | 显示全部楼层
MSK 发表于 2017-7-5 09:48
我的直接无法居中,还是麻烦不二看看

我的也无法居中,你的解决了吗
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 1 反对 0

使用道具 举报

发表于 2017-10-14 09:45:53 | 显示全部楼层

为什么啊  我不懂 求解
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2017-12-7 09:12:41 | 显示全部楼层
只能照抄,不能默写。。。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-2-1 15:20:45 | 显示全部楼层
  1. <!copytype html>
  2. <html>
  3. <head>
  4. <meta charset="uft-8">
  5. <title>0005-优化内容区设置</title>
  6. <style type="text/css">
  7.         html,body{
  8.                 height:100%;
  9.                 color:#FF0088;
  10.         }
  11.         body{
  12.                 background:url(background.jpg)center center;
  13.                 background-size:cover;
  14.         }
  15.         #container{
  16.                 width:100%;
  17.                 text-align:center;
  18.                 position:absolute;
  19.                 top:50%;
  20.                 transform:translateY(-50%);
  21.         }
  22. </style>
  23. <body
  24.         margin:0;
  25.         padding:0;
  26.         position:relative;>
  27. </head>

  28. <div id="container">
  29.         <h1>我爱鱼<h2>
  30.         <p>www.fishc.com-让编程改变世界</p>
  31.         <a href="http:///bbs.fishC.com/forum.php">鱼C论坛传送门</a>
  32.         <a href="http://xxjl.zhanghm.cc/">回到本站主页</a>
  33. </div>
  34. </body>
  35. </html>       
复制代码

360截图-162611281.jpg

评分

参与人数 2荣誉 +5 鱼币 +11 贡献 +3 收起 理由
muwan + 5 + 5 + 3 又学到了新知识,这位大哥牛逼了
不二如是 + 6 加油!

查看全部评分

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 1 反对 0

使用道具 举报

发表于 2018-2-9 03:54:34 | 显示全部楼层
挑灯夜读,精神好!
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-3-7 21:18:26 | 显示全部楼层
交作业
<!DOCTYPE html>
<html>
<head>
        <title>欢迎来到HTML世界</title>
        <style type="text/css">
                html,body{
                        height: 100%;
                        color: #FF0088;
                }
                body{
                        background: url(0004素材.jpg) center center;
                        background-size: cover;
                        margin: 0;
                        padding: 0;
                        position: relative;
                }
                #container{
                        width: 100%;
                        text-align: center;
                        position: absolute;
                        top: 50%;
                        transform:translateY(-50%);
                }
        </style>
</head>
<body>
        <div id="container">
                <h1>I love Fishc</h1>
                <p>www.fishc,com-永远爱鱼C</p>
                <a href="#">鱼C传送门</a>
        </div>
</body>
</html>
1.png

评分

参与人数 1鱼币 +6 收起 理由
不二如是 + 6 热爱鱼C^_^

查看全部评分

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-3-8 16:17:09 | 显示全部楼层
ok,好了
<!doctype html>
<html>
                <head>
                                <meta charset="utf-8">
                                <title>欢迎来到HTML世界</title>
                                <style type="text/css">
                                        html,body{
                                                height: 100%;
                                                color: #FF0088;
                                        }
                                        body{
                                                background: url(background.jpg);
                                                background-size:cover;
                                                margin: 0;
                                                padding: 0;
                                                position: relative;
                                        }
                                        #container{
                                                width: 100%;
                                                text-align: center;
                                                position: absolute;
                                                top: 50%;
                                                transform: translateY(-50%);
                                                        }
                                </style>
                </head>
                <body>
                                                <div        id="container">
                                                <h1>我爱鱼C</h1>
                                                <p>WWW.FishC.com - 继续学习</p>
                                                <a href="http://bbs.fishc.com/forum-337-1.html">传送门</a>
                                                </div>
                </body>
</html>
360截图20180308161714025.jpg

评分

参与人数 1鱼币 +6 收起 理由
不二如是 + 6 热爱鱼C^_^

查看全部评分

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-5-23 19:33:06 | 显示全部楼层
aswyamato1989 发表于 2017-7-5 08:39
同样遇到了在body之中加入"position: relative"之后,无法实现垂直居中的问题。

兄弟,好图!
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-5-28 21:12:27 | 显示全部楼层

去掉body的相对定位
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-5-28 21:14:03 | 显示全部楼层
MSK 发表于 2017-7-5 09:48
我的直接无法居中,还是麻烦不二看看

把#container的with 设置为100%看看
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-5-29 10:53:04 | 显示全部楼层
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.         <meta charset="utf-8">
  5.         <title>欢迎来到HTML世界</title>
  6.         <style type="text/css">
  7.                 html,body{
  8.                         height: 100%;
  9.                         color: #BBEEBB;
  10.                 }
  11.                 body{
  12.                         background: url(pic_02.png)center center;
  13.                         background-size: cover;
  14.                         margin: 0;
  15.                         padding:0;
  16.                         position: relative;
  17.                 }
  18.                 #container{
  19.                         width: 100%;
  20.                         text-align: center;
  21.                         position: absolute;
  22.                         top: 60%;
  23.                         transform: translateY(-50%);
  24.                 }
  25.                 #Gucci{
  26.                         width: 100%;
  27.                         text-align: center;
  28.                         position: absolute;
  29.                         top: 20%;
  30.                         transform: translateY(-50%);
  31.                 }
  32.                 #Prada{
  33.                         width: 100%;
  34.                         text-align: center;
  35.                         position: absolute;
  36.                         top: 40%;
  37.                         transform: translateY(-50%);                       
  38.                 }
  39.         </style>
  40. </head>
  41. <body>
  42.     <div id="container">
  43.         <h1>我爱鱼C</h1>
  44.         <p>WWW.FihsC.com - 让编程改变世界</p>
  45.         <a >传送门</a>
  46.     </div>
  47.     <div id="Gucci">
  48.         <h1>我爱Gucci</h1>
  49.         <p>Gucci Gucci Parada Parada</p>
  50.         <a >传送门</a>
  51.     </div>
  52.     <div id="Prada">
  53.         <h1>脚踩Prada的女魔头</h1>
  54.         <p>WWW.FihsC.com - 让编程改变世界</p>
  55.         <a >传送门</a>
  56.     </div>
  57. </body>
  58. </html>
复制代码
pic_04.png

点评

我很赞同!: 5.0
我很赞同!: 5
  发表于 2018-7-13 08:27

评分

参与人数 1鱼币 +5 收起 理由
不二如是 + 5 鱼C有你更精彩^_^

查看全部评分

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-5-29 20:06:52 | 显示全部楼层
鱿鱼酱 发表于 2017-4-11 16:33
加了transform: translateY(-50%); 木有上移,求解。。。

分号你写成中文形态下的了,换成英文的
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-6-10 13:13:39 | 显示全部楼层
<!DOCTYPE html>
<html>
        <head>
                <meta charset="utf-8">
                <title>欢迎来到html世界</title>
                <style type="text/css">
                        html,body{
                                height: 100%;
                                color: #FF0088;
                        }
                        body {
                                background: url("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1528606019071&di=1e968ad4299ede9ae69c7e69fedff785&imgtype=0&src=http%3A%2F%2F4k.znds.com%2F20140314%2F4kznds3.jpg") center center;
                                background-size: cover;
                                margin: 0;
                                padding: 0;
                                position: relative;
                        }
                        #container{
                                width: 100%;
                                text-align: center;
                                position: absolute;
                                top: 50%;
                                transform: translateY(-50%);
                        }
                </style>

        </head>
        <body>
                <div id="container">
                        <h1>我爱鱼C</h1>
                        <p>WWW.FihsC.com - 让编程改变世界</p>
                        <a href="http://bbs.fishc.com">传送门</a>
                </div>
        </body>
</html>
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-7-12 19:24:40 | 显示全部楼层
本帖最后由 STmove 于 2018-7-12 19:27 编辑

同样要注释掉position:relative才能垂直居中,求解
  1. <!DOCTYPE HTML>
  2. <!-- 0004页面美化,learned from 不二如是 -->
  3. <html>
  4. <head>
  5.     <meat charset="utf-8">
  6.     <title>welcome to the world of HTML</title>
  7.     <meta name="viewport" content="width=device-width,initial-scale=1.0">
  8.     <meta name="keywords" content="STmove,test">
  9.     <meta name="description" content="学习测试">
  10.     <meta name="author" content="STmove">
  11.    
  12.     <style type="text/css">
  13.         html
  14.         {
  15.             height:100%;
  16.         }
  17.         body
  18.         {   
  19.             background:url("320980.jpg") center center;   /*设置背景图水平和垂直位置为居中 */
  20.             background-size:cover;  /*cover:把背景图像扩展至足够大,以使背景图像完全覆盖背景区域。背景图像的某些部分也许无法显示在背景定位区域中。*/
  21.             margin:0;
  22.             padding:0;
  23.             <!-- position:relative; -->  /*相对坐标*/
  24.         }
  25.         #container
  26.         {
  27.             width:100%;
  28.             text-align: center;   /*文字位置水平居中*/
  29.             position: absolute;  /*绝对坐标*/
  30.             top:50%;            /*距顶50%*/
  31.             transform:translateY(-50%);  /*transform:该属性允许我们对元素进行旋转、缩放、移动或倾斜。translateY(-50%):沿Y轴整体上移一半*/
  32.         }
  33.         h1{color:#0bf;}
  34.         p{color:#afe;}
  35.         a{color:#fff;}
  36.     </style>
  37. </head>

  38. <body>
  39.     <div id="container">
  40.         <h1>我爱鱼兮</h1>
  41.         <p>www.FishC.org-让编程改变世界</p>
  42.         <a href="http://www.FishC.org" target="_blank">JOIN US</a>
  43.     </div>
  44. </body>
  45. </html>
复制代码

微信截图_20180712192647.png

点评

我很赞同!: 5.0
我很赞同!: 5
  发表于 2018-7-13 08:27

评分

参与人数 1鱼币 +5 收起 理由
不二如是 + 5 鱼C有你更精彩^_^

查看全部评分

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-10-11 00:04:01 | 显示全部楼层
  1. <!DOCTYPE html>
  2. <html>

  3. <head>
  4.     <title>
  5.         XXX
  6.     </title>
  7.     <meta charset="utf-8">
  8.     <style type="text/css">
  9.         html {
  10.             height: 100%;
  11.             color: #FF0088;
  12.         }
  13.         
  14.         body {
  15.             background: url(background.jpg) center center;
  16.             background-size: cover;
  17.             margin: 0;
  18.             padding: 0;
  19.             /*position: relative;*/
  20.         }
  21.         
  22.         #container {
  23.             width: 100%;
  24.             text-align: center;
  25.             position: absolute;
  26.             top: 50%;
  27.             transform: translateY(-50%);
  28.         }
  29.     </style>
  30. </head>

  31. <body>
  32.     <div id="container">
  33.         <h1>我爱鱼C</h1>
  34.         <p>www.FishC.com - 让编程改变世界</p>
  35.         <a href="http://bbs.fishc.com/forum-337-1.html">传送门</a>
  36.     </div>
  37. </body>

  38. </html>
复制代码


我也是  设置了position: relative;就没办法垂直居中
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-11-11 00:44:24 | 显示全部楼层
可以 受益匪浅
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-2-11 13:12:50 | 显示全部楼层
支持老大分享
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-24 13:43

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表