小编use*_*976的帖子

仅使用 CSS 过渡来增加价值

在我的代码中,我只想在宽度变宽时使用过渡。当宽度减小时我不需要任何动画。我可以只使用 CSS 吗?添加/删除课程对我来说不是一个选项。

function changeCss() {
  document.getElementById('squareId').style.width = "300px";
}

function reset() {
  document.getElementById('squareId').style.width = "100px";
}
Run Code Online (Sandbox Code Playgroud)
.square {
  background-color: red;
  width: 100px;
  height: 100px;
  transition: width 1s linear;
}
Run Code Online (Sandbox Code Playgroud)
<div id="squareId" class="square"></div>

<button onclick="changeCss()">increase</button>
<button onclick="reset()">decrease</button>
Run Code Online (Sandbox Code Playgroud)

JSFiddle

css transition css-transitions

5
推荐指数
1
解决办法
1612
查看次数

HttpWebResponse在循环运行时卡住了

我构建此方法(c#)以便从URL接收HTTP响应状态代码.我运行这种方法的时候它的工作正常,但是当我在一个循环中运行它时,它第三次卡住了.任何线索?

 public static string isAlive(string url)
    {
        Console.WriteLine("start: Is Alive Test");
        WebRequest request = WebRequest.Create(url);
        try
        {
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            return Convert.ToString((int)response.StatusCode);
        }
        catch(WebException ex)
        {
            HttpWebResponse res  = (HttpWebResponse)ex.Response;
            return Convert.ToString((int)res.StatusCode);
        }
    }
Run Code Online (Sandbox Code Playgroud)

循环

        for (int i = 0; i < 5; i++)
        {
            string a = isAlive("https://www.yahoo.com/");
            Console.WriteLine(a);
        }
Run Code Online (Sandbox Code Playgroud)

.net c# webrequest httpwebresponse getresponse

4
推荐指数
1
解决办法
2006
查看次数