草庐IT

html - 过渡 CSS 持续时间不起作用

coder 2023-08-10 原文

我似乎无法在我的网站上只对我的一个 div 进行持续时间转换。

如果你转到联系人部分,将鼠标悬停在 map 上,div 过渡很好

如果您将鼠标悬停在详细信息部分(带有 3 个图标的灰色区域),则该 div 向左滑动时过渡将起作用,内部 div 也是如此。

但是联系表单不想受到过渡持续时间的影响,它向左对齐。

这是网站:http://www.onepixelroom.com/londonrefurb/

代码如下:

HTML:

    <div id="contact-div">
      <div id="contact-title-box">
    <div id="contact-title">
          <h1>CONTACT</h1>
          <hr>
        </div>
  </div>
      <div id="map_canvas-antialiasing"></div>
      <div id="sliding-footer">
    <div id="map_canvas"></div>
    <div id="sliding-second">
          <div id="sliding-details">
        <div id="sliding-details-container"> <a href="mailto:hello@onethousandsheep.com?subject=Web Site Enquiry" style="text-decoration:none">
          <div class="sliding-details-box">
            <div class="sliding-details-square-hover"></div>
            <div class="sliding-details-img"><img src="http://www.onepixelroom.com/londonrefurb/img/mail.png"/></div>
            <div class="sliding-details-txt">HELLO@DRONINRENOVATIONS.COM</div>
          </div>
          </a> <a href="skype:0044750221963?call" style="text-decoration:none">
          <div class="sliding-details-box">
            <div class="sliding-details-square-hover"></div>
            <div class="sliding-details-img"><img src="http://www.onepixelroom.com/londonrefurb/img/phone.png"/></div>
            <div class="sliding-details-txt">+44 07502221963</div>
          </div>
          </a> <a href="https://maps.google.com/maps?q=10+Elm+Park+Gardens,+London+SW10+9NY,+United+Kingdom&hl=en&sll=51.487207,-0.177784&sspn=0.012146,0.021801&hnear=10+Elm+Park+Gardens,+London+SW10+9NY,+United+Kingdom&t=m&z=16"  style="text-decoration:none" target="_blank">
          <div class="sliding-details-box">
            <div class="sliding-details-square-hover"></div>
            <div class="sliding-details-img"><img src="http://www.onepixelroom.com/londonrefurb/img/home.png"/></div>
            <div class="sliding-details-txt">SOUTH KENSINGTON, LONDON UK</div>
          </div>
          </a> </div>
      </div>
          <div id="form-container">
        <div id="form-wrap">
              <form method="post" action="contactengine.php" id="commentForm">
            <fieldset>
                  <div id="formLeft">
                <label for="Name"></label>
                <div class="input-bg">
                      <input type="text" name="Name" placeholder="Name" id="Name" />
                    </div>
                <label for="Tel"></label>
                <div class="input-bg">
                      <input type="text" name="Tel" placeholder="Number" id="Tel" />
                    </div>
                <label for="Email"></label>
                <div class="input-bg">
                      <input type="text" name="Email" placeholder="Email" id="Email" />
                    </div>
              </div>
                  <div id="formRight">
                <label for="Message"></label>
                </td>
                <div class="message-bg">
                      <textarea name="Message" placeholder="Message" id="Message" rows="20" cols="20" ></textarea>
                    </div>
                <br />
                <input type="submit" name="submit" value="Submit" class="submit-button" />
              </div>
                  <div class="clear"></div>
                </fieldset>
          </form>
            </div>
      </div>
        </div>
  </div>
    </div>

CSS:

#contact-div {
    height:760px;
    float:left;
    margin:0 auto;
    width:100%;
}

#contact-title-box
{
    height:300px;
    position:relative;
}
#contact-title {
    top:110px;
    position:relative;
}
#contact-title hr {
    position:relative;
    top:30px;
    width: 230px;
    margin:0 auto;
    border: 0; 
    height: 1px; 
    background-color:#49E2D6;
}
#contact-title h1 {
    font-family: Raleway, Verdana, sans-serif;
    font-size: 50px;
    font-weight: 200;
    font-style: normal;
    letter-spacing: 3px;
    color: #3A3A3A;     
}
#sliding-footer {
    z-index: 0;
    height: 450px;
    width:100%;
}
#map_canvas-antialiasing {
    height:10px;
    position:relative;
    background-color:#FFFFFF;
    -moz-box-shadow: 0px 1px 1px rgba(0,0,0,0.1);
    -webkit-box-shadow: 0px 1px 1px rgba(0,0,0,0.1);
    box-shadow: 0px 1px 1px rgba(0,0,0,0.1);
    z-index:3;
}
#map_canvas {
    float:left;
    width: 100%;
    height: 450px;
    cursor: url(http://www.onepixelroom.com/londonrefurb/img/cursor.png) 21 26, move;
}
#map_canvas:hover + #sliding-second
{
left:45%;   
}
#sliding-second {
    background-color: #dce9e8;
    position: absolute;
    left: 20%;
    width: 80%;
    height: 450px;
    z-index:3;
    margin: 0 auto;
    -webkit-transition: 0.2s;
    -moz-transition: 0.2s;
    -o-transition: 0.2s;
    transition: 0.2s;
}
#sliding-details {
    width: 700px;
    height: 450px;
    background-color: #363636;
    position: absolute;
    -webkit-transition: 0.2s;
    -moz-transition: 0.2s;
    -o-transition: 0.2s;
    transition: 0.2s;
    left:-100px;
}
#sliding-details-container {
    float: left;
    top: 103px;
    margin: 0 auto;
    width: 400px;
    height: 200px;
    position: relative;
    left:25px;
    -webkit-transition: 0.2s;
    -moz-transition: 0.2s;
    -o-transition: 0.2s;
    transition: 0.2s;
}
.sliding-details-box:hover .sliding-details-square-hover{
    transform: translate(0,-50px);
    -webkit-transform: translate(0,-50px);
    -o-transform: translate(0,-50px);
    -moz-transform: translate(0,-50px);
}
.sliding-details-box {
    margin-bottom:50px;
    height: 50px;
    width: 400px;
    -webkit-transition: 0.2s;
    -moz-transition: 0.2s;
    -o-transition: 0.2s;
    transition: 0.2s;
    overflow:hidden;
}
.sliding-details-box:hover{
cursor: url(http://www.onethousandsheep.com/img/cursor.png) 21 26, move;    
}
.sliding-details-square-hover {
    float: left;
    background: #FFFFFF;
    background: -moz-linear-gradient(top, #FFFFFF 50%, #49E2D6 50%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(50%,#FFFFFF), color-stop(50%,#49E2D6));
    background: -webkit-linear-gradient(top, #FFFFFF 50%,#49E2D6 50%);
    background: -o-linear-gradient(top, #FFFFFF 50%,#49E2D6 50%);
    background: -ms-linear-gradient(top, #FFFFFF 50%,#49E2D6 50%); 
    background: linear-gradient(to bottom, #FFFFFF 50%,#49E2D6 50%);
    position: relative;
    border: none;
    width: 50px;
    height: 100px;
    -webkit-transition: 0.2s;
    -moz-transition: 0.2s;
    -o-transition: 0.2s;
    transition: 0.2s;
}
.sliding-details-img img {
    border: none;
    position:relative;
    top:15px;
    width: 20px;
    height: 20px;
}
.sliding-details-img {
    position:absolute;
    width: 50px;
    height: 50px;
}
.sliding-details-txt {
    z-index: 2;
    float: left;
    position: relative;
    top: 16px;
    margin-left: 30px;
    width: 300px;
    text-align: left;
    font-family: 'Droid Sans', serif;
    font-size: 14px;
    font-weight: 800;
    color: #dce0df;
    -webkit-transition: 0.2s;
    -moz-transition: 0.2s;
    -o-transition: 0.2s;
    transition: 0.2s;
    letter-spacing:2px;
    overflow:hidden;
}
#sliding-details:hover + #form-container {
    left:600px;
}
#sliding-details:hover #sliding-details-container {
    left:14%;   
}
#form-container {
    background-color: #49E2D6;
    height: 450px;
    width: 100%;
    position:relative;
    z-index:3;
    -webkit-transition: 0.2s;
    -moz-transition: 0.2s;
    -o-transition: 0.2s;
    transition: 0.2s;
}
#form-wrap {
    width: 1000px;
    background-color: #49E2D6;
    height: 300px;
    position: relative;
    margin: 0 auto;
    top:85px;
    z-index:3;
}

最佳答案

您必须为 form-container 设置一个初始的 left 值。如果没有初始左值,浏览器不知道从哪里开始设置悬停值的动画。

#form-container {
    background-color: #49E2D6;
    height: 450px;
    width: 100%;
    position:relative;
    z-index:3;
    left: 0; // This one is important!
    -webkit-transition: 0.2s;
    -moz-transition: 0.2s;
    -o-transition: 0.2s;
    transition: 0.2s;
}

这应该可以解决您的问题。

关于html - 过渡 CSS 持续时间不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21375518/

有关html - 过渡 CSS 持续时间不起作用的更多相关文章

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

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

  2. ruby - capybara field.has_css?匹配器 - 2

    我在MiniTest::Spec和Capybara中使用以下规范:find_field('Email').must_have_css('[autofocus]')检查名为“电子邮件”的字段是否具有autofocus属性。doc说如下:has_css?(path,options={})ChecksifagivenCSSselectorisonthepageorcurrentnode.据我了解,字段“Email”是一个节点,因此调用must_have_css绝对有效!我做错了什么? 最佳答案 通过JonasNicklas得到了答案:No

  3. ruby-on-rails - Rails HTML 请求渲染 JSON - 2

    在我的Controller中,我通过以下方式在我的index方法中支持HTML和JSON:respond_todo|format|format.htmlformat.json{renderjson:@user}end在浏览器中拉起它时,它会自然地以HTML呈现。但是,当我对/user资源进行内容类型为application/json的curl调用时(因为它是索引方法),我仍然将HTML作为响应。如何获取JSON作为响应?我还需要说明什么? 最佳答案 您应该将.json附加到请求的url,提供的格式在routes.rb的路径中定义。这

  4. ruby-on-rails - 如果 Object::try 被发送到一个 nil 对象,为什么它会起作用? - 2

    如果您尝试在Ruby中的nil对象上调用方法,则会出现NoMethodError异常并显示消息:"undefinedmethod‘...’fornil:NilClass"然而,有一个tryRails中的方法,如果它被发送到一个nil对象,它只返回nil:require'rubygems'require'active_support/all'nil.try(:nonexisting_method)#noNoMethodErrorexceptionanymore那么try如何在内部工作以防止该异常? 最佳答案 像Ruby中的所有其他对象

  5. ruby-on-rails - 使用 Sublime Text 3 突出显示 HTML 背景语法中的 ERB? - 2

    所以我在关注Railscast,我注意到在html.erb文件中,ruby代码有一个微弱的背景高亮效果,以区别于其他代码HTML文档。我知道Ryan使用TextMate。我正在使用SublimeText3。我怎样才能达到同样的效果?谢谢! 最佳答案 为SublimeText安装ERB包。假设您安装了SublimeText包管理器*,只需点击cmd+shift+P即可获得命令菜单,然后键入installpackage并选择PackageControl:InstallPackage获取包管理器菜单。在该菜单中,键入ERB并在看到包时选择

  6. ruby-on-rails - Ruby 检查日期时间是否为 iso8601 并保存 - 2

    我需要检查DateTime是否采用有效的ISO8601格式。喜欢:#iso8601?我检查了ruby​​是否有特定方法,但没有找到。目前我正在使用date.iso8601==date来检查这个。有什么好的方法吗?编辑解释我的环境,并改变问题的范围。因此,我的项目将使用jsapiFullCalendar,这就是我需要iso8601字符串格式的原因。我想知道更好或正确的方法是什么,以正确的格式将日期保存在数据库中,或者让ActiveRecord完成它们的工作并在我需要时间信息时对其进行操作。 最佳答案 我不太明白你的问题。我假设您想检查

  7. ruby-on-rails - 将 Ruby 中的日期/时间格式化为 YYYY-MM-DD HH :MM:SS - 2

    这个问题在这里已经有了答案:Railsformattingdate(4个答案)关闭4年前。我想格式化Time.Now函数以显示YYYY-MM-DDHH:MM:SS而不是:“2018-03-0909:47:19+0000”该函数需要放在时间中.现在功能。require‘roo’require‘roo-xls’require‘byebug’file_name=ARGV.first||“Template.xlsx”excel_file=Roo::Spreadsheet.open(“./#{file_name}“,extension::xlsx)xml=Nokogiri::XML::Build

  8. ruby-on-rails - Ruby url 到 html 链接转换 - 2

    我正在使用Rails构建一个简单的聊天应用程序。当用户输入url时,我希望将其输出为html链接(即“url”)。我想知道在Ruby中是否有任何库或众所周知的方法可以做到这一点。如果没有,我有一些不错的正则表达式示例代码可以使用... 最佳答案 查看auto_linkRails提供的辅助方法。这会将所有URL和电子邮件地址变成可点击的链接(htmlanchor标记)。这是文档中的代码示例。auto_link("Gotohttp://www.rubyonrails.organdsayhellotodavid@loudthinking.

  9. ruby - 查找字符串中的内容类型(数字、日期、时间、字符串等) - 2

    我正在尝试解析一个CSV文件并使用SQL命令自动为其创建一个表。CSV中的第一行给出了列标题。但我需要推断每个列的类型。Ruby中是否有任何函数可以找到每个字段中内容的类型。例如,CSV行:"12012","Test","1233.22","12:21:22","10/10/2009"应该产生像这样的类型['integer','string','float','time','date']谢谢! 最佳答案 require'time'defto_something(str)if(num=Integer(str)rescueFloat(s

  10. ruby-on-rails - capybara ::ElementNotFound:无法找到 xpath "/html" - 2

    我正在学习http://ruby.railstutorial.org/chapters/static-pages上的RubyonRails教程并遇到以下错误StaticPagesHomepageshouldhavethecontent'SampleApp'Failure/Error:page.shouldhave_content('SampleApp')Capybara::ElementNotFound:Unabletofindxpath"/html"#(eval):2:in`text'#./spec/requests/static_pages_spec.rb:7:in`(root)'

随机推荐