MDL复选框问题:不希望标签激活复选框

时间:2016-09-30 11:31:53

标签: javascript html checkbox material-design

我有一个Material Design Lite复选框,其标签包含指向Ts& Cs的链接;但点击该链接会激活该复选框。代码如下所示:

label

我真的不希望该链接激活该复选框。我尝试过将div重命名为div s,将label移到public class Test { public static IFooController iFooController => (IFooController) new object(); public static FooRequest CreateRequest<T>(Expression<Func<FooResponse<T>>> func) { return FooRequest.Create(func); } public static void Main() { var newRequest = CreateRequest(() => iFooController.GetEmployeeById("myPartner", 42, DateTime.Now.AddDays(-1))); Console.ReadKey(); } } public class FooRequest { public static FooRequest Create<T>(Expression<Func<FooResponse<T>>> func) { var call = (MethodCallExpression) func.Body; var arguments = new List<object>(); foreach (var arg in call.Arguments) { var constant = arg as ConstantExpression; if (constant != null) { arguments.Add(constant.Value); } else { var evaled = Expression.Lambda(arg).Compile().DynamicInvoke(); arguments.Add(evaled); } } return new FooRequest(call.Method.Name, arguments.ToArray()); } public FooRequest(string function, object[] data = null) { //SendRequestToServiceBus(function, data); Console.Write($"Function name: {function}"); } } public class FooResponse<T> { } public interface IFooController { FooResponse<string> GetEmployeeById(string partnerName, int employeeId, DateTime? ifModifiedSince); } 以外,等等,但是找不到合适的解决方案。

我已经在MDL网站上查了一下,似乎没有标准方法以这种方式配置复选框。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

将链接放在标签外的单独范围内,然后将标签的宽度设置为“auto”,这样它就不会占用整行。 (并使用vertical-align:middle对齐链接)

<label mdl class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-1" style="width:auto">
  <input mdl type="checkbox" id="checkbox-1" class="mdl-checkbox__input" [(ngModel)]="loginRegisterData.termsConditions" #termsConditions (keyup.enter)="clickRegisterButton()">
  <span class="mdl-checkbox__label">I agree to the </span>
</label>
<span class="mdl-checkbox__label" style="vertical-align: middle"><a (click)="setVisiblePanel(5)" class="mouseHand">Terms and Conditions</a></span>

请参阅小提琴:jsfiddle.net/yn8Ltt56