我在Visual Studio 2013中使用ASP.NET Web表单。
我正在使用以下CSS代码段作为按钮,
.button::before {
content: '';
position: absolute;
background: #071017;
border: 50vh solid #1d4567;
width: 30vh;
height: 30vh;
border-radius: 50%;
display: block;
top: 50%;
left: 50%;
z-index: 0;
opacity: 1;
-webkit-transform: translate(-50%, -50%) scale(0);
transform: translate(-50%, -50%) scale(0);
}
和
.button:active::before, .button:focus::before {
-webkit-transition: opacity 0.28s ease 0.364s, -webkit-transform 1.12s ease;
transition: opacity 0.28s ease 0.364s, -webkit-transform 1.12s ease;
transition: transform 1.12s ease, opacity 0.28s ease 0.364s;
transition: transform 1.12s ease, opacity 0.28s ease 0.364s, -webkit-transform 1.12s ease;
-webkit-transform: translate(-50%, -50%) scale(1);
transform: translate(-50%, -50%) scale(1);
opacity: 0;
}
它适用于html按钮,但不适用于ASP.NET按钮。
<div class="button-container">
<asp:Button ID="submit" class="button" runat="server" Text="Submit" OnClick="submit_Click" />
<button type="submit" class="button"><span>Submit</span></button>
</div>
这是我的ASP.NET网络表单
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OrderTakingUI.aspx.cs" Inherits="ResponsiveWebApplication.OrderTakingUI" %>
<!DOCTYPE html>
<html>
<head>
<title>Orders</title>
<meta charset='UTF-8'>
<style>
@import url(http://fonts.googleapis.com/css?family=Roboto);
body,
input,
select,
textarea,
body * {
font-family: 'Roboto', sans-serif;
box-sizing: border-box;
}
body::after, body::before,
input::after,
input::before,
select::after,
select::before,
textarea::after,
textarea::before,
body *::after,
body *::before {
box-sizing: border-box;
}
body {
background-image: -webkit-linear-gradient(top, #f2f2f2, #e6e6e6);
background-image: linear-gradient(top, #f2f2f2, #e6e6e6);
}
h1 {
font-size: 2rem;
text-align: center;
margin: 0 0 2em;
}
.container {
max-width: 40rem;
margin: 2rem auto;
background: #fff;
width: 100%;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
padding: 3rem 5rem 0;
border-radius: 1px;
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transition: box-shadow 0.28s ease, -webkit-transform 0.28s ease;
transition: box-shadow 0.28s ease, -webkit-transform 0.28s ease;
transition: box-shadow 0.28s ease, transform 0.28s ease;
transition: box-shadow 0.28s ease, transform 0.28s ease, -webkit-transform 0.28s ease;
}
fieldset {
margin: 0 0 3rem;
padding: 0;
border: none;
}
/*------------------------------input type text and textarea and other starts-----*/
.form-inline > .form-group,
.form-inline > .btn {
display: inline-block;
margin-bottom: 0;
}
.form-help {
margin-top: 0.125rem;
margin-left: 0.125rem;
color: #b3b3b3;
font-size: 0.8rem;
}
.form-group input {
height: 1.9rem;
}
.form-group textarea {
resize: none;
}
.form-group select {
width: 100%;
font-size: 1rem;
height: 1.6rem;
padding: 0.125rem 0.125rem 0.0625rem;
background: none;
border: none;
line-height: 1.6;
box-shadow: none;
}
.form-group .input-label {
position: absolute;
top: 0.25rem;
pointer-events: none;
padding-left: 0.125rem;
z-index: 1;
color: #b3b3b3;
font-size: 1rem;
font-weight: normal;
-webkit-transition: all 0.28s ease;
transition: all 0.28s ease;
}
.form-group .bar {
position: relative;
border-bottom: 0.0625rem solid #999;
display: block;
}
.form-group .bar::before {
content: '';
height: 0.125rem;
width: 0;
left: 50%;
bottom: -0.0625rem;
position: absolute;
background: #B73394;
-webkit-transition: left 0.28s ease, width 0.28s ease;
transition: left 0.28s ease, width 0.28s ease;
z-index: 2;
}
.form-group input,
.form-group textarea {
display: block;
background: none;
padding: 0.125rem 0.125rem 0.0625rem;
font-size: 1rem;
border-width: 0;
border-color: transparent;
line-height: 1.9;
width: 100%;
color: transparent;
-webkit-transition: all 0.28s ease;
transition: all 0.28s ease;
box-shadow: none;
}
.form-group input[type="file"] {
line-height: 1;
}
.form-group input[type="file"] ~ .bar {
display: none;
}
.form-group select,
.form-group input:focus,
.form-group input:valid,
.form-group input.form-file,
.form-group input.has-value,
.form-group textarea:focus,
.form-group textarea:valid,
.form-group textarea.form-file,
.form-group textarea.has-value {
color: #333;
}
.form-group select ~ .input-label,
.form-group input:focus ~ .input-label,
.form-group input:valid ~ .input-label,
.form-group input.form-file ~ .input-label,
.form-group input.has-value ~ .input-label,
.form-group textarea:focus ~ .input-label,
.form-group textarea:valid ~ .input-label,
.form-group textarea.form-file ~ .input-label,
.form-group textarea.has-value ~ .input-label {
font-size: 0.8rem;
color: gray;
top: -1rem;
left: 0;
}
.form-group select:focus,
.form-group input:focus,
.form-group textarea:focus {
outline: none;
}
.form-group select:focus ~ .input-label,
.form-group input:focus ~ .input-label,
.form-group textarea:focus ~ .input-label {
color: #B73394;
}
.form-group select:focus ~ .bar::before,
.form-group input:focus ~ .bar::before,
.form-group textarea:focus ~ .bar::before {
width: 100%;
left: 0;
}
.form-group {
position: relative;
margin-top: 2.25rem;
margin-bottom: 2.25rem;
}
/*------------------------------input type text and textarea and other ends-----*/
/*--------------------------------Button starts--------------------------------*/
.button-container {
text-align: center;
}
.button {
position: relative;
background: currentColor;
border: 1px solid currentColor;
font-size: 1.1rem;
color: #B73394;
margin: 3rem 0;
padding: 0.75rem 3rem;
cursor: pointer;
-webkit-transition: background-color 0.28s ease, color 0.28s ease, box-shadow 0.28s ease;
transition: background-color 0.28s ease, color 0.28s ease, box-shadow 0.28s ease;
overflow: hidden;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
}
.button span {
color: #fff;
position: relative;
z-index: 1;
}
.button::before {
content: '';
position: absolute;
background: #071017;
border: 50vh solid #1d4567;
width: 30vh;
height: 30vh;
border-radius: 50%;
display: block;
top: 50%;
left: 50%;
z-index: 0;
opacity: 1;
-webkit-transform: translate(-50%, -50%) scale(0);
transform: translate(-50%, -50%) scale(0);
}
.button:hover {
color: #B73394;
box-shadow: 0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12), 0 3px 5px -1px rgba(0, 0, 0, 0.2);
}
.button:active::before, .button:focus::before {
-webkit-transition: opacity 0.28s ease 0.364s, -webkit-transform 1.12s ease;
transition: opacity 0.28s ease 0.364s, -webkit-transform 1.12s ease;
transition: transform 1.12s ease, opacity 0.28s ease 0.364s;
transition: transform 1.12s ease, opacity 0.28s ease 0.364s, -webkit-transform 1.12s ease;
-webkit-transform: translate(-50%, -50%) scale(1);
transform: translate(-50%, -50%) scale(1);
opacity: 0;
}
.button:focus {
outline: none;
}
/*--------------------------------Button ends--------------------------------
</style>
</head>
<body>
<div class="container">
<form id="form1" runat="server" method="post">
<div class="form-group">
<asp:DropDownList ID="DropDownList1" runat="server" required=""></asp:DropDownList>
<label for="select" class="input-label">Selectbox</label><i class="bar"></i>
</div>
<div class="form-group">
<asp:TextBox ID="text" runat="server" required="required"></asp:TextBox>
<label for="input" class="input-label">Textfield</label><i class="bar"></i>
</div>
<div class="form-group">
<asp:TextBox id="textarea" TextMode="multiline" Columns="50" Rows="5" runat="server" required="required" />
<label for="textarea" class="input-label">Textarea</label><i class="bar"></i>
</div>
<div class="button-container">
<asp:Button ID="submit" class="button" runat="server" Text="Submit" OnClick="submit_Click" />
<button type="submit" class="button"><span>Submit</span></button>
</div>
</form>
</div>
</body>
</html>
我没有太多使用CSS和ASP.NET的经验。我期待着你的帮助。
答案 0 :(得分:3)
如果你想在asp.net控件中使用css类,请使用CssClass而不是下面的类。
<asp:Button ID="submit" CssClass="button" runat="server" Text="Submit" OnClick="submit_Click" />
在客户端渲染后找出控件的id。然后在该id上实现CSS。如果你使用id而不是css类。
答案 1 :(得分:1)
对于asp.button
,您应该使用CssClass
代替class
:
<asp:Button ID="submit" CssClass="button" runat="server" Text="Submit" OnClick="submit_Click" />