草庐IT

html - 如何修复 float html div 的布局和大小?

coder 2023-08-10 原文

下面是有问题的html

默认显示为:

这是完全错误的,它应该在两行上,它也应该看起来“漂亮”,但现在看起来很丑。

这个盒子的目的是让它看起来像一个“正在加载”的盒子,在加载后(已经合并到我的主要代码中)它会在加载后消失,所以目前唯一的问题是它看起来很丑而且布局不正确:(

我在主 div 中有两个 div block 的原因是因为它们将是不同大小和颜色的文本(我认为)

如果有人认为我愿意使用外观完全不同的加载消息/栏/弹出窗口,请随时发布。

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <style type="text/css">
            .loading1 a {
            position: fixed;
            cursor: pointer;
            left: 50%;
            top: 10%;
            color: white;
            padding-left: 5px;
            }

            .loading2 a {
            position: fixed;
            cursor: pointer;
            left: 50%;
            top: 10%;
            color: white;
            padding-left: 5px;
            }

            .loading {
            z-index: 999;
            position: fixed;
            left: 50%;
            top: 10%;
            width: 150px;
            height: 80px;
            border: 1px solid white;
            -moz-border-radius: 10px;
            border-radius: 10px;
            background: #D8B93F;
            }

            #circularG{
            position:relative;
            width:25px;
            height:25px}

            .circularG{
            position:absolute;
            background-color:#0E4216;
            width:6px;
            height:6px;
            -moz-border-radius:4px;
            -moz-animation-name:bounce_circularG;
            -moz-animation-duration:1.12s;
            -moz-animation-iteration-count:infinite;
            -moz-animation-direction:linear;
            -webkit-border-radius:4px;
            -webkit-animation-name:bounce_circularG;
            -webkit-animation-duration:1.12s;
            -webkit-animation-iteration-count:infinite;
            -webkit-animation-direction:linear;
            -o-border-radius:4px;
            -o-animation-name:bounce_circularG;
            -o-animation-duration:1.12s;
            -o-animation-iteration-count:infinite;
            -o-animation-direction:linear;
            -ms-border-radius:4px;
            -ms-animation-name:bounce_circularG;
            -ms-animation-duration:1.12s;
            -ms-animation-iteration-count:infinite;
            -ms-animation-direction:linear;
            }

            #circularG_1{
            left:0;
            top:10px;
            -moz-animation-delay:0.42s;
            -webkit-animation-delay:0.42s;
            -o-animation-delay:0.42s;
            -ms-animation-delay:0.42s;
            }

            #circularG_2{
            left:3px;
            top:3px;
            -moz-animation-delay:0.56s;
            -webkit-animation-delay:0.56s;
            -o-animation-delay:0.56s;
            -ms-animation-delay:0.56s;
            }

            #circularG_3{
            top:0;
            left:10px;
            -moz-animation-delay:0.7s;
            -webkit-animation-delay:0.7s;
            -o-animation-delay:0.7s;
            -ms-animation-delay:0.7s;
            }

            #circularG_4{
            right:3px;
            top:3px;
            -moz-animation-delay:0.84s;
            -webkit-animation-delay:0.84s;
            -o-animation-delay:0.84s;
            -ms-animation-delay:0.84s;
            }

            #circularG_5{
            right:0;
            top:10px;
            -moz-animation-delay:0.98s;
            -webkit-animation-delay:0.98s;
            -o-animation-delay:0.98s;
            -ms-animation-delay:0.98s;
            }

            #circularG_6{
            right:3px;
            bottom:3px;
            -moz-animation-delay:1.12s;
            -webkit-animation-delay:1.12s;
            -o-animation-delay:1.12s;
            -ms-animation-delay:1.12s;
            }

            #circularG_7{
            left:10px;
            bottom:0;
            -moz-animation-delay:1.26s;
            -webkit-animation-delay:1.26s;
            -o-animation-delay:1.26s;
            -ms-animation-delay:1.26s;
            }

            #circularG_8{
            left:3px;
            bottom:3px;
            -moz-animation-delay:1.4s;
            -webkit-animation-delay:1.4s;
            -o-animation-delay:1.4s;
            -ms-animation-delay:1.4s;
            }

            @-moz-keyframes bounce_circularG{
            0%{
            -moz-transform:scale(1)}

            100%{
            -moz-transform:scale(.3)}

            }

            @-webkit-keyframes bounce_circularG{
            0%{
            -webkit-transform:scale(1)}

            100%{
            -webkit-transform:scale(.3)}

            }

            @-o-keyframes bounce_circularG{
            0%{
            -o-transform:scale(1)}

            100%{
            -o-transform:scale(.3)}

            }

            @-ms-keyframes bounce_circularG{
            0%{
            -ms-transform:scale(1)}

            100%{
            -ms-transform:scale(.3)}

            }
        </style>
    </head>
    <body>
        <div class="loading"><div id="circularG">
            <div id="circularG_1" class="circularG">
            </div>
            <div id="circularG_2" class="circularG">
            </div>
            <div id="circularG_3" class="circularG">
            </div>
            <div id="circularG_4" class="circularG">
            </div>
            <div id="circularG_5" class="circularG">
            </div>
            <div id="circularG_6" class="circularG">
            </div>
            <div id="circularG_7" class="circularG">
            </div>
            <div id="circularG_8" class="circularG">
            </div>
        </div>
        <div class="loading1"><a>Loading, Please Wait...</a></div><div class="loading2"><br><a>(click to abort)</a></div></div>
    </body>
</html>

谢谢

最佳答案

加载框内的任何内容都不需要 position:fixedtopleft。我还对定位和间距做了一些更改。希望你喜欢!

http://jsfiddle.net/myajouri/9eZNQ/

HTML

<div class="loading">
    <div id="circularG">
        <div id="circularG_1" class="circularG"></div>
        <div id="circularG_2" class="circularG"></div>
        <div id="circularG_3" class="circularG"></div>
        <div id="circularG_4" class="circularG"></div>
        <div id="circularG_5" class="circularG"></div>
        <div id="circularG_6" class="circularG"></div>
        <div id="circularG_7" class="circularG"></div>
        <div id="circularG_8" class="circularG"></div>
    </div>
    <div class="loadingText">
        Loading, Please Wait... 
        <a href="#">(click to abort)</a>
    </div>
</div>

CSS

.loadingText {
    color: white;
    font-family: sans-serif;
    font-size: 16px;
}
.loadingText a {
    line-height: 32px;
    color: inherit;
    font-size: 14px;
    text-decoration: none;
}
.loading {
    z-index: 999;
    position: fixed;
    left: 50%;
    top: 50%;
    width: 170px;
    height: 90px;
    margin-left: -95px;
    margin-top: -55px;
    padding: 10px;
    border: 1px solid white;
    -moz-border-radius: 10px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.75);
    text-align: center;
}
#circularG {
    position:relative;
    width:25px;
    height:25px;
    margin: 5px auto 15px auto;
}
.circularG {
    position:absolute;
    background-color: white;
    width:6px;
    height:6px;
    -moz-border-radius:4px;
    -moz-animation-name:bounce_circularG;
    -moz-animation-duration:1.12s;
    -moz-animation-iteration-count:infinite;
    -moz-animation-direction:linear;
    -webkit-border-radius:4px;
    -webkit-animation-name:bounce_circularG;
    -webkit-animation-duration:1.12s;
    -webkit-animation-iteration-count:infinite;
    -webkit-animation-direction:linear;
    -o-border-radius:4px;
    -o-animation-name:bounce_circularG;
    -o-animation-duration:1.12s;
    -o-animation-iteration-count:infinite;
    -o-animation-direction:linear;
    -ms-border-radius:4px;
    -ms-animation-name:bounce_circularG;
    -ms-animation-duration:1.12s;
    -ms-animation-iteration-count:infinite;
    -ms-animation-direction:linear;
}
#circularG_1 {
    left:0;
    top:10px;
    -moz-animation-delay:0.42s;
    -webkit-animation-delay:0.42s;
    -o-animation-delay:0.42s;
    -ms-animation-delay:0.42s;
}
#circularG_2 {
    left:3px;
    top:3px;
    -moz-animation-delay:0.56s;
    -webkit-animation-delay:0.56s;
    -o-animation-delay:0.56s;
    -ms-animation-delay:0.56s;
}
#circularG_3 {
    top:0;
    left:10px;
    -moz-animation-delay:0.7s;
    -webkit-animation-delay:0.7s;
    -o-animation-delay:0.7s;
    -ms-animation-delay:0.7s;
}
#circularG_4 {
    right:3px;
    top:3px;
    -moz-animation-delay:0.84s;
    -webkit-animation-delay:0.84s;
    -o-animation-delay:0.84s;
    -ms-animation-delay:0.84s;
}
#circularG_5 {
    right:0;
    top:10px;
    -moz-animation-delay:0.98s;
    -webkit-animation-delay:0.98s;
    -o-animation-delay:0.98s;
    -ms-animation-delay:0.98s;
}
#circularG_6 {
    right:3px;
    bottom:3px;
    -moz-animation-delay:1.12s;
    -webkit-animation-delay:1.12s;
    -o-animation-delay:1.12s;
    -ms-animation-delay:1.12s;
}
#circularG_7 {
    left:10px;
    bottom:0;
    -moz-animation-delay:1.26s;
    -webkit-animation-delay:1.26s;
    -o-animation-delay:1.26s;
    -ms-animation-delay:1.26s;
}
#circularG_8 {
    left:3px;
    bottom:3px;
    -moz-animation-delay:1.4s;
    -webkit-animation-delay:1.4s;
    -o-animation-delay:1.4s;
    -ms-animation-delay:1.4s;
}
@-moz-keyframes bounce_circularG {
    0% {
        -moz-transform:scale(1)
    }
    100% {
        -moz-transform:scale(.3)
    }
}
@-webkit-keyframes bounce_circularG {
    0% {
        -webkit-transform:scale(1)
    }
    100% {
        -webkit-transform:scale(.3)
    }
}
@-o-keyframes bounce_circularG {
    0% {
        -o-transform:scale(1)
    }
    100% {
        -o-transform:scale(.3)
    }
}
@-ms-keyframes bounce_circularG {
    0% {
        -ms-transform:scale(1)
    }
    100% {
        -ms-transform:scale(.3)
    }
}

关于html - 如何修复 float html div 的布局和大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20403091/

有关html - 如何修复 float html div 的布局和大小?的更多相关文章

  1. ruby - 如何使用 Nokogiri 的 xpath 和 at_xpath 方法 - 2

    我正在学习如何使用Nokogiri,根据这段代码我遇到了一些问题:require'rubygems'require'mechanize'post_agent=WWW::Mechanize.newpost_page=post_agent.get('http://www.vbulletin.org/forum/showthread.php?t=230708')puts"\nabsolutepathwithtbodygivesnil"putspost_page.parser.xpath('/html/body/div/div/div/div/div/table/tbody/tr/td/div

  2. ruby - 如何从 ruby​​ 中的字符串运行任意对象方法? - 2

    总的来说,我对ruby​​还比较陌生,我正在为我正在创建的对象编写一些rspec测试用例。许多测试用例都非常基础,我只是想确保正确填充和返回值。我想知道是否有办法使用循环结构来执行此操作。不必为我要测试的每个方法都设置一个assertEquals。例如:describeitem,"TestingtheItem"doit"willhaveanullvaluetostart"doitem=Item.new#HereIcoulddotheitem.name.shouldbe_nil#thenIcoulddoitem.category.shouldbe_nilendend但我想要一些方法来使用

  3. ruby-on-rails - 在 Rails 中将文件大小字符串转换为等效千字节 - 2

    我的目标是转换表单输入,例如“100兆字节”或“1GB”,并将其转换为我可以存储在数据库中的文件大小(以千字节为单位)。目前,我有这个:defquota_convert@regex=/([0-9]+)(.*)s/@sizes=%w{kilobytemegabytegigabyte}m=self.quota.match(@regex)if@sizes.include?m[2]eval("self.quota=#{m[1]}.#{m[2]}")endend这有效,但前提是输入是倍数(“gigabytes”,而不是“gigabyte”)并且由于使用了eval看起来疯狂不安全。所以,功能正常,

  4. python - 如何使用 Ruby 或 Python 创建一系列高音调和低音调的蜂鸣声? - 2

    关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。

  5. ruby-on-rails - 如何验证 update_all 是否实际在 Rails 中更新 - 2

    给定这段代码defcreate@upgrades=User.update_all(["role=?","upgraded"],:id=>params[:upgrade])redirect_toadmin_upgrades_path,:notice=>"Successfullyupgradeduser."end我如何在该操作中实际验证它们是否已保存或未重定向到适当的页面和消息? 最佳答案 在Rails3中,update_all不返回任何有意义的信息,除了已更新的记录数(这可能取决于您的DBMS是否返回该信息)。http://ar.ru

  6. ruby-on-rails - 'compass watch' 是如何工作的/它是如何与 rails 一起使用的 - 2

    我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t

  7. ruby - 使用 ruby​​ 将 HTML 转换为纯文本并维护结构/格式 - 2

    我想将html转换为纯文本。不过,我不想只删除标签,我想智能地保留尽可能多的格式。为插入换行符标签,检测段落并格式化它们等。输入非常简单,通常是格式良好的html(不是整个文档,只是一堆内容,通常没有anchor或图像)。我可以将几个正则表达式放在一起,让我达到80%,但我认为可能有一些现有的解决方案更智能。 最佳答案 首先,不要尝试为此使用正则表达式。很有可能你会想出一个脆弱/脆弱的解决方案,它会随着HTML的变化而崩溃,或者很难管理和维护。您可以使用Nokogiri快速解析HTML并提取文本:require'nokogiri'h

  8. ruby - 如何将脚本文件的末尾读取为数据文件(Perl 或任何其他语言) - 2

    我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚

  9. ruby - 如何指定 Rack 处理程序 - 2

    Rackup通过Rack的默认处理程序成功运行任何Rack应用程序。例如:classRackAppdefcall(environment)['200',{'Content-Type'=>'text/html'},["Helloworld"]]endendrunRackApp.new但是当最后一行更改为使用Rack的内置CGI处理程序时,rackup给出“NoMethodErrorat/undefinedmethod`call'fornil:NilClass”:Rack::Handler::CGI.runRackApp.newRack的其他内置处理程序也提出了同样的反对意见。例如Rack

  10. ruby - 如何每月在 Heroku 运行一次 Scheduler 插件? - 2

    在选择我想要运行操作的频率时,唯一的选项是“每天”、“每小时”和“每10分钟”。谢谢!我想为我的Rails3.1应用程序运行调度程序。 最佳答案 这不是一个优雅的解决方案,但您可以安排它每天运行,并在实际开始工作之前检查日期是否为当月的第一天。 关于ruby-如何每月在Heroku运行一次Scheduler插件?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/8692687/

随机推荐