简体   繁体   English

自定义CSS按钮动画在MVC C#部分视图中不起作用

[英]Custom CSS Button Animation Not Working in MVC C# Partial View

I have a custom css button that is supposed fill up from the bottom. 我有一个自定义的CSS按钮,应该从底部填满。 I am working in an MVC C# project and specifically a partial view is giving me trouble. 我正在MVC C#项目中工作,特别是局部视图给我带来了麻烦。

The custom button works on normal views but the fill on hover never gets rendered for some reason. 自定义按钮可在普通视图上使用,但由于某些原因永远不会呈现悬停时的填充。 Only the color of the text changes on hover. 悬停时仅文本的颜色会更改。 The css 'before' action never seems to get rendered. css的“之前”动作似乎从未得到渲染。 What am I missing? 我想念什么? Hopefully I am missing something obvious! 希望我缺少明显的东西!

 .custom-up-btn-request { position: relative; display: inline-block; margin-bottom: 0; text-align: center; vertical-align: middle; margin: 15px 0px; padding: 5px 10px; font-size: 16px; color: blue; border: 2px blue solid; border-radius: 4px; outline: 0; overflow: hidden; background: none; z-index: 1; cursor: pointer; transition: 0.08s ease-in; -o-transition: 0.08s ease-in; -ms-transition: 0.08s ease-in; -moz-transition: 0.08s ease-in; -webkit-transition: 0.08s ease-in; } .custom-up-btn-request:focus { color: blue; text-decoration: none; } .up-btn-request-fill:hover { color: lawngreen; text-decoration: none; } .up-btn-request-fill:before { content: ""; position: absolute; background: blue; bottom: 0; left: 0; right: 0; top: 100%; z-index: -1; -webkit-transition: top 0.09s ease-in; } .up-btn-request-fill:hover:before { top: 0; } 
 <div class="form-group"> <div class="control-label col-md-3"><b>Submit Change Request</b></div> <div class="col-md-5"> <textarea class="form-control" rows="6" cols="20" id="ChangesText" name="ChangesText" placeholder="Put any changes you need."></textarea> </div> <div class="col-md-4"></div> </div> <div class="form-group"> <div class="col-md-offset-3 col-md-9"> <input type="submit" value="Submit Request" class="custom-up-btn-request up-btn-request-fill" /> </div> </div> 

Thanks in advance! 提前致谢!

Have a look at this codepen :) the first button should be your solution. 看看这个 codepen :)第一个按钮应该是您的解决方案。 For any reason it does not work with an input. 由于任何原因,它不适用于输入。 Just take the button tag and there you go... Here is the content applied to your example code: 只需获取button标记,就可以开始...这是应用于示例代码的内容:

 .custom-up-btn-request { position: relative; display: inline-block; margin-bottom: 0; text-align: center; vertical-align: middle; margin: 15px 0px; padding: 5px 10px; font-size: 16px; color: blue; border: 2px blue solid; border-radius: 4px; outline: 0; overflow: hidden; background: none; z-index: 1; cursor: pointer; transition: 0.08s ease-in; -o-transition: 0.08s ease-in; -ms-transition: 0.08s ease-in; -moz-transition: 0.08s ease-in; -webkit-transition: 0.08s ease-in; } .custom-up-btn-request:focus { color: blue; text-decoration: none; } .up-btn-request-fill:hover { color: lawngreen; text-decoration: none; } .up-btn-request-fill:before { content: ""; position: absolute; background: blue; bottom: 0; left: 0; right: 0; top: 100%; z-index: -1; -webkit-transition: top 0.09s ease-in; } .up-btn-request-fill:hover:before { top: 0; } 
 <div class="form-group"> <div class="control-label col-md-3"><b>Submit Change Request</b></div> <div class="col-md-5"> <textarea class="form-control" rows="6" cols="20" id="ChangesText" name="ChangesText" placeholder="Put any changes you need."></textarea> </div> <div class="col-md-4"></div> </div> <div class="form-group"> <div class="col-md-offset-3 col-md-9"> <buttontype="submit" class="custom-up-btn-request up-btn-request-fill"/>Submit Request</button </div> </div> 

<input type="submit" /> doesn't play nice with pesudo styling :before and :after You're going to want to have to use <button class="custom-up-btn-request up-btn-request-fill">Submit</button> <input type="submit" />不能与假样式一起使用:before:after您将不得不使用<button class="custom-up-btn-request up-btn-request-fill">Submit</button>

fiddle link: http://jsbin.com/wakiretaco/1/edit?html,css,output 小提琴链接: http : //jsbin.com/wakiretaco/1/edit?html,css,output

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM