Hi,
ich möchte dass der Text links und die Buttons rechts immer schön untereinander bleiben, leider tun sie das nur wenn auch 3 oder 2 Charaktere vorhanden sind. Sonst ist der Text und die Buttons über das ganze Bild verteilt. Wie kann ich das ordentlich umsetzen?
<html>
<head>
<link href="characterselect.css" rel="stylesheet">
<link href="bootstrap.min.css" rel="stylesheet">
<script src="jquery.js"></script>
</head>
<body style="background-color: transparent;" onload="mp.trigger('CharacterSelectLoaded');">
<div class="blurry"></div>
<div class="box">
<div class="center">
<img src="Logo.png" class="logo"></img>
<h1><strong>Charakterauswahl</strong></h1>
<p class="lead boxtext">Bitte waehle einen Charakter aus.</p>
<div id="charbox1">
<p id="char1text" class="lead boxtext charboxp"><strong></strong></p>
</div>
<div id="charbox2">
<p id="char2text" class="lead boxtext charboxp"><strong></strong></p>
</div>
<div id="charbox3">
<p id="char3text" class="lead boxtext charboxp"><strong></strong></p>
</div>
</div>
</div>
<script>
function loadData(char1, char2, char3)
{
if(char1 !== "undefined")
{
let charbox = document.getElementById("charbox1");
let DelBtn = document.createElement("input");
DelBtn.setAttribute('id', "char1delete");
DelBtn.setAttribute('type', "submit");
DelBtn.setAttribute('class', "charboxinput");
DelBtn.setAttribute('value', "Loeschen");
let PlayBtn = document.createElement("input");
PlayBtn.setAttribute('id', "char1");
PlayBtn.setAttribute('type', "submit");
PlayBtn.setAttribute('class', "charboxinput");
PlayBtn.setAttribute('value', "Spielen");
charbox.appendChild(DelBtn);
charbox.appendChild(PlayBtn);
document.getElementById("char1text").innerHTML = `<strong>${char1}</strong><br>`;
}
else
{
let charbox = document.getElementById("charbox1");
let CreateBtn = document.createElement("input");
CreateBtn.setAttribute('id', "char1create");
CreateBtn.setAttribute('type', "submit");
CreateBtn.setAttribute('class', "charboxinput");
CreateBtn.setAttribute('value', "Erstellen");
charbox.appendChild(CreateBtn);
document.getElementById("char1text").innerHTML = `<strong>Nicht vorhanden</strong><br>`;
}
if(char2 !== "undefined")
{
let charbox = document.getElementById("charbox2");
let DelBtn = document.createElement("input");
DelBtn.setAttribute('id', "char2delete");
DelBtn.setAttribute('type', "submit");
DelBtn.setAttribute('class', "charboxinput");
DelBtn.setAttribute('value', "Loeschen");
let PlayBtn = document.createElement("input");
PlayBtn.setAttribute('id', "char2");
PlayBtn.setAttribute('type', "submit");
PlayBtn.setAttribute('class', "charboxinput");
PlayBtn.setAttribute('value', "Spielen");
charbox.appendChild(DelBtn);
charbox.appendChild(PlayBtn);
document.getElementById("char2text").innerHTML = `<strong>${char2}</strong><br>`;
}
else
{
let charbox = document.getElementById("charbox2");
let CreateBtn = document.createElement("input");
CreateBtn.setAttribute('id', "char2create");
CreateBtn.setAttribute('type', "submit");
CreateBtn.setAttribute('class', "charboxinput");
CreateBtn.setAttribute('value', "Erstellen");
charbox.appendChild(CreateBtn);
document.getElementById("char2text").innerHTML = `<strong>Nicht vorhanden</strong><br>`;
}
if(char3 !== "undefined")
{
let charbox = document.getElementById("charbox3");
let DelBtn = document.createElement("input");
DelBtn.setAttribute('id', "char3delete");
DelBtn.setAttribute('type', "submit");
DelBtn.setAttribute('class', "charboxinput");
DelBtn.setAttribute('value', "Loeschen");
let PlayBtn = document.createElement("input");
PlayBtn.setAttribute('id', "char3");
PlayBtn.setAttribute('type', "submit");
PlayBtn.setAttribute('class', "charboxinput");
PlayBtn.setAttribute('value', "Spielen");
charbox.appendChild(DelBtn);
charbox.appendChild(PlayBtn);
document.getElementById("char3text").innerHTML = `<strong>${char3}</strong><br>`;
}
else
{
let charbox = document.getElementById("charbox3");
let CreateBtn = document.createElement("input");
CreateBtn.setAttribute('id', "char3create");
CreateBtn.setAttribute('type', "submit");
CreateBtn.setAttribute('class', "charboxinput");
CreateBtn.setAttribute('value', "Erstellen");
charbox.appendChild(CreateBtn);
document.getElementById("char3text").innerHTML = `<strong>Nicht vorhanden</strong><br>`;
}
}
</script>
</body>
</html>
Alles anzeigen
Die CSS:
.blurry
{
background-color: #000;
opacity: 0.7;
height: 100%;
width: 100%;
position: absolute;
z-index: 99;
}
.box{
width: 600px;
padding: 40px;
position: absolute;
z-index: 100;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
background: #191914;
text-align: center;
}
.box h1{
color: white;
text-transform: uppercase;
font-weight: 500;
}
.boxtext{
color: white;
}
.box input[type = "text"],.box input[type = "password"]{
border:0;
background: none;
display: block;
margin: 20px auto;
text-align: center;
border: 2px solid #3498db;
padding: 14px 10px;
width: 280px;
outline: none;
color: white;
border-radius: 24px;
transition: 0.25s;
}
.box input[type = "text"]:focus,.box input[type = "password"]:focus{
width: 300px;
border-color: #2ecc71;
}
.box input[type = "submit"]{
border:0;
background: none;
display: inline-block;
margin: 10px auto;
text-align: center;
border: 2px solid #2ecc71;
padding: 14px 40px;
outline: none;
color: white;
border-radius: 24px;
transition: 0.25s;
cursor: pointer;
}
.box input[type = "submit"]:hover{
background: #2ecc71;
}
.charboxp
{
margin-top: 25px;
float: left;
}
.charboxinput
{
float: right;
margin-right: 5px;
}
#char1delete, #char2delete, #char3delete
{
border: 2px solid #d6260f;
}
#char1delete:hover, #char2delete:hover, #char3delete:hover
{
background: #d6260f;
}
#char1create, #char2create, #char3create
{
border: 2px solid #858585;
}
#char1create:hover, #char2create:hover, #char3create:hover
{
background: #858585;
}
.logo
{
width: 300px;
height: 300px;
margin-top: -60px;
margin-bottom: -20px;
}
Alles anzeigen
Und so sieht es bisher aus: