是否可以使用CSS隐藏空输入文本?
.textbox{
display: block;
}
.textbox[value=""]{
display: none;// всегда видно
}
.textbox:not([value]){
display: none;// всегда скрыто
}
脑子里什么也没有想到。有CSS方式吗?
是否可以使用CSS隐藏空输入文本?
.textbox{
display: block;
}
.textbox[value=""]{
display: none;// всегда видно
}
.textbox:not([value]){
display: none;// всегда скрыто
}
脑子里什么也没有想到。有CSS方式吗?
开关处的边框动画不会随着位置的变化而起作用。禁用时, animation: rotation 1s linear infinite;
滑块会移动
@keyframes rotation {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
input{
position: relative;
-webkit-appearance:none;
width: 60px;
height: 6px;
background: #e4e4e4;
border-radius: 5px;
cursor: pointer;
}
input:before{
content: "";
position: absolute;
top:-12px;
left:0;
width: 30px;
height: 30px;
background:#ccc;
border-radius: 50%;
transition: 0.5s;
border:1px solid #ccc;
}
input:checked:before{
transform: translateX(30px);
background:#ffbd45;
border: 1px solid #ffbd45;
border-bottom-color: #FF3D00;
//animation: rotation 1s linear infinite;
}
input.c1:checked:after{
width:0;
border-radius: 10px;
left:20%;
transform: translate(30px,-50%);
}
<input type="checkbox">
一个文件没问题:
ffmpeg -i "%~1" "%~n1.gif"
如何处理一组多个拖放文件?
尝试过:
for %%a in (%*) do (
ffmpeg "%%a~1" "%%a~n1.gif"
)
不起作用。
$.ajax({
crossDomain: true,
type: "GET",
url: "url",
data: {a:"a",b:"b"},
dataType: "xml",
});
如何在 C# 中格式化数据对象?
WebRequest wr = WebRequest.Create(url);
wr.Method = "GET";
wr.Headers["dataType"] = "xml";
wr.Headers["data"] = ?;
试过了
wr.Headers["data"] = "{a:1234,b:\"b\"}";
回答Wrong input data
服务器应返回文件以供下载。英文名称一切正常,俄语我无法分配正常名称。
例子:
byte[] fromb64 = Convert.FromBase64String(file);
string fname = Encoding.UTF8.GetString(fromb64);
Console.WriteLine("Decoded base64 = " + fname);// тут все нормально
response.AddHeader("Content-disposition", "attachment; filename=" + Path.GetFileName(fname));// а тут нет. получается бурда из символов
response.ContentLength64 = file_Stream.Length;
response.SendChunked = false;
response.ContentType = System.Net.Mime.MediaTypeNames.Application.Octet;
试图直截了当
response.AddHeader("Content-disposition", "attachment; filename=\"файл.jpg\"");
我收到 D09;.jpg
有解决办法吗?
您需要通过单击托盘图标来显示/隐藏窗口。
目前:如果窗口在隐藏时被最小化,它也被显示为最小化,同样在最大化时。我怎样才能使它在显示最小化窗口时显示在屏幕上并出现在前台?“最大化”是指正常视图,而不是全屏
notifyicon.MouseClick += new System.Windows.Forms.MouseEventHandler(showhideform);
private void showhideform(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
if (Visibility == Visibility.Visible)
{
Hide();
ShowInTaskbar = false;
}
else
{
Show();
ShowInTaskbar = true;
}
}
}
该列表可以包含 2 种类型的元素:文本和链接。ObservableCollection 可能包含相应不同的对象,带有type="url"
或type="text"
class Item
{
string type;
string title;
string titleshort;
string time;
}
collection.Add(new Item{type="url",title="http://url",time=datetime});
collection.Add(new Item{type="text",title="text text text ....", titleshort="text ..." ,time=datetime});
<ItemsControl>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel IsItemsHost="True"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border>
<TextBlock Tag="{Binding title}"
Cursor="Hand"
TextWrapping="Wrap">
<Run Text="{Binding titleshort}" PreviewMouseDown="openTextFromHistory"/>
<Run Text="{Binding timeblock}"/>
</TextBlock>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
В случае url шаблон должен быть таким:
<Border>
<TextBlock>
<Hyperlink NavigateUri="{Binding title}">
<Run Text="{Binding title}"/>
</Hyperlink>
<Run Text="{Binding time}"/>
</TextBlock>
</Border>
В случае text таким:
<Border>
<TextBlock Tag="title" PreviewMouseLeftButtonDown="somemethod">
<Run Text="{Binding titleshort}"/>
<Run Text="{Binding time}"/>
</TextBlock>
</Border>
如何插入所需的模板取决于type
?
MainWindow.xaml 中的UPD命名空间:
x:Class="RemoteControl.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:RemoteControl"
mc:Ignorable="d"
缩短了函数 querySelector 和 querySelectorAll
function get(s){
return document.querySelector(s);
}
function getAll(s){
return document.querySelectorAll(s);
}
NodeList.prototype.get=function(s){
return this.querySelector(s)
}
NodeList.prototype.getAll=function(s){
return this.querySelectorAll(s)
}
申请:
el=getAll("#dbdata tr")[r].getAll("td")[c].get(".cell")
控制台说.getAll is not a function
解决方案?
我正在制作一堆 C# TcpListner + JS Websocket。建立连接,传输数据。问题是在建立连接(握手)后,处理器一直以 25% 的速度加载。我认为问题出在 while 循环中,但我也有一个具有相同循环的 HttpListener 并且未加载处理器。如何解决问题?取自此处的示例
class TcpServer
{
public string ip;
public int port;
private Thread bgThread;
public void StartListen()
{
bgThread = new Thread(new ThreadStart(Start))
{
IsBackground = true,
Name = "MyTcpListener"
};
bgThread.Start();
}
public void Start()
{
TcpListener server = new TcpListener(IPAddress.Parse(ip), port);
server.Start();
Console.WriteLine("Server has started on {0}:{1}, Waiting for a connection...", ip, port);
TcpClient client = server.AcceptTcpClient();
Console.WriteLine("A client connected.");
NetworkStream stream = client.GetStream();
while (true)
{
//Console.WriteLine("loop");
while (!stream.DataAvailable) ;
while (client.Available < 3) ; // match against "get"
byte[] bytes = new byte[client.Available];
stream.Read(bytes, 0, client.Available);
string strbytes = Encoding.UTF8.GetString(bytes);
if (Regex.IsMatch(strbytes, "^GET", RegexOptions.IgnoreCase))
{
Console.WriteLine("=====Handshaking from client=====\n{0}", strbytes);
// 1. Obtain the value of the "Sec-WebSocket-Key" request header without any leading or trailing whitespace
// 2. Concatenate it with "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" (a special GUID specified by RFC 6455)
// 3. Compute SHA-1 and Base64 hash of the new value
// 4. Write the hash back as the value of "Sec-WebSocket-Accept" response header in an HTTP response
string swk = Regex.Match(strbytes, "Sec-WebSocket-Key: (.*)").Groups[1].Value.Trim();
string swka = swk + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
byte[] swkaSha1 = System.Security.Cryptography.SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(swka));
string swkaSha1Base64 = Convert.ToBase64String(swkaSha1);
// HTTP/1.1 defines the sequence CR LF as the end-of-line marker
byte[] response = Encoding.UTF8.GetBytes(
"HTTP/1.1 101 Switching Protocols\r\n" +
"Connection: Upgrade\r\n" +
"Upgrade: websocket\r\n" +
"Sec-WebSocket-Accept: " + swkaSha1Base64 + "\r\n\r\n");
stream.Write(response, 0, response.Length);
}
else
{
//Console.WriteLine("strbytes: " + strbytes);
bool fin = (bytes[0] & 0b10000000) != 0,
mask = (bytes[1] & 0b10000000) != 0; // must be true, "All messages from the client to the server have this bit set"
int opcode = bytes[0] & 0b00001111, // expecting 1 - text message
msglen = bytes[1] - 128, // & 0111 1111
offset = 2;
if (msglen == 126)
{
// was ToUInt16(bytes, offset) but the result is incorrect
msglen = BitConverter.ToUInt16(new byte[] { bytes[3], bytes[2] }, 0);
offset = 4;
}
else if (msglen == 127)
{
Console.WriteLine("TODO: msglen == 127, needs qword to store msglen");
// i don't really know the byte order, please edit this
// msglen = BitConverter.ToUInt64(new byte[] { bytes[5], bytes[4], bytes[3], bytes[2], bytes[9], bytes[8], bytes[7], bytes[6] }, 0);
// offset = 10;
}
if (msglen == 0)
Console.WriteLine("msglen == 0");
else if (mask)
{
byte[] decoded = new byte[msglen];
byte[] masks = new byte[4] { bytes[offset], bytes[offset + 1], bytes[offset + 2], bytes[offset + 3] };
offset += 4;
for (int i = 0; i < msglen; ++i)
decoded[i] = (byte)(bytes[offset + i] ^ masks[i % 4]);
string text = Encoding.UTF8.GetString(decoded);
Console.WriteLine("{0}", text);
}
else
Console.WriteLine("mask bit not set");
Console.WriteLine();
}
}
}
}
JS
let socket = new WebSocket("ws://192.168.1.149:1112");
function startup() {
var el =document.getElementById("mousePad");
el.addEventListener("touchstart", handleStart, false);
el.addEventListener("touchend", handleEnd, false);
el.addEventListener("touchcancel", handleCancel, false);
el.addEventListener("touchleave", handleEnd, false);
el.addEventListener("touchmove", handleMove, false);
log("initialized.");
//socket = new WebSocket("ws://192.168.1.149:1112");
log("state: "+socket.readyState)
socket.onopen = function(e) {
log("state onopen: "+socket.readyState)
log("[open] Соединение установлено");
};
socket.onclose = function (e) {
log("DISCONNECTED");
};
socket.onerror = function(error) {
log("[error]"+error.message);
};
}
您需要在画布上显示特殊字符 alpha (α)
ctx.fillText("α",50,195);
输出相同的文本α
如何绘制特殊字符?
需要一个嵌套数组
[[1, 2, 3, 4, 5, 6, 7, 8, 9],
[2, 3, 4, 5, 6, 7, 8, 9, 1],
[3, 4, 5, 6, 7, 8, 9, 1, 2],
[4, 5, 6, 7, 8, 9, 1, 2, 3],
[5, 6, 7, 8, 9, 1, 2, 3, 4],
[6, 7, 8, 9, 1, 2, 3, 4, 5],
[7, 8, 9, 1, 2, 3, 4, 5, 6],
[8, 9, 1, 2, 3, 4, 5, 6, 7],
[9, 1, 2, 3, 4, 5, 6, 7, 8]]
let arr=[];
var a=[1,2,3,4,5,6,7,8,9];
arr[0]=a;
for (let i = 1; i < 9; i++) {
a.push(a.shift());
arr[i]=a;
console.log(arr[i]) //1
}
console.log(arr); //2
在第一个输出中,结果正确,在第二个输出中,它看起来像这样:
[1, 2, 3, 4, 5, 6, 7, 8, 9],
[1, 2, 3, 4, 5, 6, 7, 8, 9],
[1, 2, 3, 4, 5, 6, 7, 8, 9],
[1, 2, 3, 4, 5, 6, 7, 8, 9],
[1, 2, 3, 4, 5, 6, 7, 8, 9],
[1, 2, 3, 4, 5, 6, 7, 8, 9],
[1, 2, 3, 4, 5, 6, 7, 8, 9],
[1, 2, 3, 4, 5, 6, 7, 8, 9],
[1, 2, 3, 4, 5, 6, 7, 8, 9]
为什么?有数组自动排序吗?
姓氏、名字、父名和出生日期输入到表格中。一个人可以注册多次。
name1 text -- name2 text -- name3 text -- birthdate datetime
帮助编写一个查询,该查询将选择每个人而不重复
遍历名称中包含空格的文件
for %%i in (*.mp3) do
ffmpeg -i %%i -codec:a libmp3lame -b:a 128k %%~ni_128.mp3
)
由于空格,脚本无法找到该文件。怎么做才能让名字读完整?
我在一个文件夹中有许多 320 比特率的 mp3 文件。如何使用 ffmpeg.exe 转换所有 bat 文件,例如最高 96 kbps 的同名文件并保存到另一个文件夹?
在表格列date_in
和date_out
“10.14.19”形式的
列中string
在程序中,我得到一个周期,例如,从“10/14/19”到“11/01/19”
您需要选择适合所选间隔date_in
或date_out
指定一个边界的行。例如,date_in
然后选择此日期之后的所有内容
试过了
WHERE Date(date_in)>Date("14.10.19")
WHERE date_in>"14/10/19"
我得到月份的日期大于指定日期的行,月份和年份被忽略,
你可以写和
DateTime dt=Convert.ToDateTime(datetime);
WHERE DAY(date_in)>dt.Day and MONTH(date_in)
等等 但我希望它更短。
有一个 ul 有几个 li。我需要复制前 3 个并添加到另一个块
<ul>
<li>текст</li>
<li>текст</li>
<li>текст</li>
<li>текст</li>
<li>текст</li>
<li>текст</li>
<li>текст</li>
</ul>
<ul id="otherBlock"></ul>
使用 jQuery 很容易:
$elems=$("选择器").slice(0,3).clone()
有纯js等价物吗?
您需要从文本中提取以下行:
<coverpage><image l:href="#cover.jpg"/></coverpage>
编译了一个正则表达式,没有
在网站https://regex101.com/r/zcTpqR/2@"<coverpage><image l:href=""#(.*?)""/></coverpage>"
上检查
匹配
它可以工作,虽然这个 \" 引号变体,但在程序中不起作用
"<coverpage><image l:href=\"#(.*?)\"/></coverpage>"
升级版:
xdoc = new XDocument();
xdoc = XDocument.Load(opf.FileName);
string xdocstr = xdoc.ToString();
string t1 = Regex.Replace(xdocstr, @"<FictionBook[^>]*>", "<FictionBook>");//убираю неймспейсы потому что уже голова болит от возни с ними
MatchCollection mcol = Regex.Matches(t1, @"<coverpage><image l:href=""#(.*?)""/></coverpage>");
string coverStr = "";
foreach (Match m in mcol)
{
coverStr += m.Groups[1].Value + "\n";//строка пустая
}
我不会把这本书的全文贴出来,它很大。如果有用,这里是完整文件https://yadi.sk/d/NKpYCB4UoZlXLw
<?xml version="1.0" encoding="utf-8"?>
<FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:l="http://www.w3.org/1999/xlink">
<description>
<title-info>
<genre>sf</genre>
<author>
<first-name>Айзек</first-name>
<last-name>Азимов</last-name>
</author>
<book-title>Профессия</book-title>
<annotation>
<i>
На Земле, по прошествии 4-5 тысяч лет система образования, естественно, претерпела массу изменений и нововедений. В восемь лет все дети должны были пройти День Чтения, когда соответствующая программа с ленты, обучающей чтению, за 15 минут переписывалась в мозг ребенка. В 18 лет на Дне Знаний компьютер выбирал для человека его оптимальную профессию и закладывал в его мозг соответствующую программу. Затем каждый год проводились Олимпиады, где планеты, требующие специалистов, отбирали себе лучших.
Джордж Пленетей страстно хотел стать программистом и тайком от всех изучал книги по програмированию. Но в 18 лет в День знаний компьютер выбрал ему совсем другую специальность.
</i>
</annotation>
<date>1957</date>
<1-- вот это нужно достать -->
<coverpage><image l:href="#cover.jpg"/></coverpage>
<lang>ru</lang>
<src-lang>en</src-lang>
<translator>
<first-name>Светлана</first-name>
<last-name>Васильева</last-name>
</translator>
<sequence number='0' name='Шедевры фантастики'/>
</title-info>
有 2 个列表框,您需要在其中选择项目。失去焦点时,所选项目的背景颜色变为灰色。如何设置样式以更改此颜色?
<ListBox.ItemContainerStyle>
<Style>
<Style.Triggers>
<Trigger Property="Selector.IsFocused" Value="True">
<Setter Property="TextElement.Background" Value="Blue"/>
</Trigger>
<Trigger Property="Selector.IsFocused" Value="False">
<Setter Property="TextElement.Background" Value="Red"/>
</Trigger>
</Style.Triggers>
</Style>
</ListBox.ItemContainerStyle>