JavaScriptアラートボックスの幅と高さを設定するにはどうすればよいですか?
JavaScriptでアラートボックスの幅と高さを設定するには、カスタムアラートボックスを使用する必要があります。このアラートボックスはCSSでスタイル設定されています。
例
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
</script>
<script>
function functionAlert(msg, myYes)
{
var confirmBox = $("#confirm");
confirmBox.find(".message").text(msg);
confirmBox.find(".yes").unbind().click(function()
{
confirmBox.hide();
});
confirmBox.find(".yes").click(myYes);
confirmBox.show();
}
</script>
<style>
#confirm
{
display: none;
background-color: #F3F5F6;
color: #000000;
border: 1px solid #aaa;
position: fixed;
width: 300px;
height: 100px;
left: 50%;
margin-left: -100px;
padding: 10px 20px 10px;
box-sizing: border-box;
text-align: center;
}
#confirm button {
background-color: #FFFFFF;
display: inline-block;
border-radius: 12px;
border: 4px solid #aaa;
padding: 5px;
text-align: center;
width: 60px;
cursor: pointer;
}
#confirm .message
{
text-align: left;
}
</style>
</head>
<body>
<div id="confirm">
<div class = "message">This is a warning message.</div><br>
<button class="yes">OK</button>
</div>
<input type="button" value="Click Me" onclick="functionAlert();" />
</body>
</html> -
JavaScriptで画面の利用可能な高さと利用可能な幅を取得するにはどうすればよいですか?
window.screen オブジェクトは、ブラウザ画面に関する情報を取得するための多くの機能を提供しています。 screen.availWidthを提供しています およびscreen.availHeight 利用可能な高さを取得するには および使用可能な幅 画面の。それらについて個別に話し合いましょう。 使用可能な幅 例 screen.availWidth プロパティは、訪問者の画面の実際の幅を返します。これは、Windowsタスクバーなどのインターフェイス機能の幅を差し引くことを意味します。結果の値はピクセルになります 。 <html> <body>
-
AndroidでImageViewの幅と高さをプログラムで設定するにはどうすればよいですか?
この例は、AndroidでImageViewの幅と高さをプログラムで設定する方法を示しています ステップ1 − Android Studioで新しいプロジェクトを作成し、[ファイル]⇒[新しいプロジェクト]に移動して、新しいプロジェクトを作成するために必要なすべての詳細を入力します。 ステップ2 −次のコードをres / layout/activity_main.xmlに追加します。 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="