我正在使用CSS flexbox重建网站.
在检查浏览器兼容性时,我发现所有现代浏览器都支持flexbox,但Safari 8和IE 10需要供应商前缀.
在检查Google Analytics时,我发现过去6个月内96%的网站访问者使用完全支持flexbox的浏览器.其余4%使用需要前缀或不提供支持的浏览器.
由于我们讨论的是4%的用户,并且数量会越来越小,(我希望尽可能保持我的代码干净简单),我考虑不使用前缀,而是要求用户升级他们的浏览器.
如何定位旧浏览器以向用户显示要求他们更新浏览器的消息?
这是我到目前为止所拥有的:
<!--[if IE]>
<div class="browserupgrade">
<p>You are using an outdated browser. Please <a href="http://browsehappy.com/">
upgrade your browser</a> to improve your experience.</p>
</div>
<![endif]-->
Run Code Online (Sandbox Code Playgroud)
这个IE条件评论涵盖了IE版本6,7,8和9.
这些访问者将收到一条警报,其中包含下载当前浏览器的链接.但是,Microsoft已停止支持从IE10开始的条件评论.
现在我需要类似的东西:
是否有一个简单的JS/jQuery脚本来处理这个工作?或另一种轻量级方法?
感谢所有的答案.很明显,有很多方法可以解决这个问题(Modernizr,PHP,jQuery函数,普通的Javascript,CSS,browser-update.org等).这些方法中的许多方法都能完全有效地完成这项工作.
我选择了最简单的一个:CSS(信用卡@LGSon).
除了IE <= 7之外,这个CSS基本上涵盖了所有目标浏览器.
.browserupgrade { display: block; }
_:-ms-fullscreen, :root .browserupgrade { display: none; }
:-o-prefocus, .browserupgrade { display: none; }
@supports (display: flex) { …
Run Code Online (Sandbox Code Playgroud) 我正在准备从ASP.NET Core 2.2迁移到3.0。
As I don't use any more advanced JSON features (but maybe one as described below), and 3.0 now comes with a built-in namespace/classes for JSON, System.Text.Json
, I decided to see if I could drop the previous default Newtonsoft.Json
. Do note, I'm aware that System.Text.Json
will not completely replace Newtonsoft.Json
.
I managed to do that everywhere, e.g.
var obj = JsonSerializer.Parse<T>(jsonstring);
var jsonstring = JsonSerializer.ToString(obj);
Run Code Online (Sandbox Code Playgroud)
but in one place, where I populate an existing object. …
c# asp.net-core razor-pages asp.net-core-3.0 system.text.json
===
和==
,!==
和== 之间有什么区别...什么时候应该使用另一个?什么时候应该使用另一个?
我试图把一个中心<v-btn>
变成一个<v-flex>
.由于<v-flex>
是一个flexbox div,我使用justify-center
它转换成
justify-content: center
Run Code Online (Sandbox Code Playgroud)
由于我的方向是水平的,我的按钮应该居中对齐,但事实并非如此.这是重现我的问题的codepen.
https://codepen.io/anon/pen/ZXLzex
我想注册按钮在div(v-flex)内居中.
这是完整的代码:
<v-card>
<v-card-text >
<v-text-field label="Email"></v-text-field>
<v-text-field label="Password"></v-text-field>
</v-card-text>
<v-card-actions>
<v-layout row>
<v-flex justify-center>
<v-btn primary>
Signup
</v-btn>
</v-flex>
</v-layout>
</v-card-actions>
</v-card>
Run Code Online (Sandbox Code Playgroud) 以下代码使用脚本在第二次单击时收听无线电切换/取消选中.
我的问题是如何仅使用CSS执行此操作?
(function(lastimg) {
document.querySelector("#img-select").addEventListener('click', function(e){
if (e.target.tagName.toLowerCase() == 'input') {
if (lastimg == e.target) {
e.target.checked = false;
lastimg = null;
} else {
lastimg = e.target;
}
}
});
}());
Run Code Online (Sandbox Code Playgroud)
.container {
display: flex;
flex-wrap: wrap;
max-width: 660px;
}
.container > label {
flex: 1;
flex-basis: 33.333%;
}
.container > div {
flex: 1;
flex-basis: 100%;
}
.container label img {
display: block;
margin: 0 auto;
}
.container input, .container input ~ div { …
Run Code Online (Sandbox Code Playgroud)我把文字放在这样的一个<textarea>
:
First day
1-one apple.
2-one orange.
3-two cups of milk.
Run Code Online (Sandbox Code Playgroud)
但它显示<label>
如下:
First day 1- one apple. 2-one orange. 3- two cups of milks.
Run Code Online (Sandbox Code Playgroud)
如何让它看起来像在一个<textarea>
?
我将视图的一部分移到了部分视图。
_ViewImports.cshtml
@using AsonCore.Helpers
@using AsonCore.Models
@namespace AsonCore.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
Run Code Online (Sandbox Code Playgroud)
Application.cshtml
@page
@model ApplicationModel
<partial name="/Pages/Partial/_ApplicationPartial.cshtml" />
Run Code Online (Sandbox Code Playgroud)
_ApplicationPartial.cshtml
@model ApplicationModel
<section class="content application">
<div>
<form method="post" enctype="multipart/form-data">
<div>
<label asp-for='email.Firstname'>FORNAVN</label>
<input asp-for='email.Firstname' required />
</div>
<div>
<label asp-for="email.Lastname">ETTERNAVN</label>
<input asp-for="email.Lastname" required />
</div>
<div>
<input type="submit" value="Send" />
</div>
</form>
<partial name="/Pages/Shared/_FormScript.cshtml" />
</div>
</section>
Run Code Online (Sandbox Code Playgroud)
_Project.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<RootNamespace>AsonCore</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Content Remove="Pages\Partial\**" />
</ItemGroup>
<ItemGroup>
<None Include="Pages\Partial\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference …
Run Code Online (Sandbox Code Playgroud) 在下面的代码和jsfiddle中,flexbox比例随内容而变化.我觉得我不明白这里的flexbox的真正目的.如果我们flex-grow
按照我们想要的比例提供物业,为什么箱子会随着内容的增长而增长?
请注意,当其中dataDiv
包含新的跨度内容时,比例会随内容而中断.删除span
内部时,您可以观察它的预期比例dataDiv
.为什么会这样?
https://jsfiddle.net/4shaz5oy/
.container {
display: flex;
flex-flow: row wrap;
height: 100vh;
}
.mapBox {
flex: 2;
background-color: red;
}
.controlBox {
flex: 1;
display: flex;
flex-direction: column;
background-color: green;
}
.controlPanel {
flex: 1;
max-height: 33%;
background-color: yellow;
padding: 5px;
text-align: center;
}
.dataPanel {
flex: 2;
max-height: 66%;
background-color: blue;
padding: 5px;
}
Run Code Online (Sandbox Code Playgroud)
<div class="container">
<div class="mapBox"></div>
<div class="controlBox">
<div class="controlPanel">
<div class="buttonDiv"></div>
<div class="buttonDiv"></div>
<div class="buttonDiv"></div>
</div>
<div class="dataPanel"> …
Run Code Online (Sandbox Code Playgroud)由于新的Bootstrap 4正在从使用" 浮动 "元素迁移到更好的" flexbox "方法,只是想知道使用.d-flex
而不是现有.container .row .col
方法构建整个网格结构是否可行?
由于它们都是使用flexbox从根本上构建的,所以我看不出任何替换它们的缺点.事实上,我觉得.d-flex
需要更少的css类名,并使html中的内容更具可读性.
我还有其他原因d-flex
比旧的更好col
:
水平和垂直元素 - d-flex支持水平(.flex-row)和垂直(.flex-column)创建元素.Col仅支持水平.
内联元素 - 元素的宽度将继承自子元素,并且可以使用d-inline-flex动态对齐.col网格是固定的.
提前重新订购 - d-flex使用.order-x
和col使用.push
和.pull
.在我看来,d-flex
更直观的是,元素的顺序通过编号来表示,另一方面,数字的数量.col
是从前一个状态推动和拉开的网格数量.当你构建一个更复杂的网站时,它会变得混乱....
如果我错了,请纠正我.
使用JsonSerialize.DeserializeAsync
自定义转换器反序列化,例如
public class MyStringJsonConverter : JsonConverter<string>
{
public override string Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return reader.GetString();
}
public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOptions options)
{
throw new NotImplementedException();
}
}
Run Code Online (Sandbox Code Playgroud)
在这里我将获得所有 string
属性,这还可以,但是有什么方法可以检查给定值的属性名称,例如这样的东西,在哪里只处理属性Body
:
class MyMailContent
{
public string Name { get; set; }
public string Subject { get; set; }
public string Body { get; set; }
}
public class MyStringJsonConverter : JsonConverter<string>
{
public override string Read(ref Utf8JsonReader …
Run Code Online (Sandbox Code Playgroud) css ×5
css3 ×4
flexbox ×4
html ×4
c# ×3
asp.net-core ×2
javascript ×2
razor-pages ×2
equals ×1
jquery ×1
label ×1
line-breaks ×1
literals ×1
vuejs2 ×1
vuetify.js ×1