需要将3个盒子移到左侧

时间:2017-10-28 08:56:29

标签: html css

我有问题!我点了一个按钮就可以看到3个盒子。问题是盒子向右移动。他们需要向左移动一点点。我试图用一个大的div来修复它,它将设置为left:5%;但它没有帮助......如果你不知道我想说什么,这就是图片 - The problem。请改变我的代码,谢谢! :d

body, html {
    height: 100%;
    margin: 0px;
}
body {
    background-size: auto 120%;
    background-repeat: no-repeat;
    background-position: right !important;
}
  
ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #0074D9;
}

li {
    float: left;
}

li a {
    display: block;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
	color: white !important;
	font-family:arial;
}

li a:hover:not(.active) {
    background-color: #0047b3 !important;
}

.active {
    background-color:#0047b3;
}

a:link{
	color:#0074D9;
}
a:visited{
	color:#0074D9;
}
a:hover{
	color:#001f3f;
}
a:active{
	color:#001f3f;
}

hr{
	height:3px;
	background-color:#0080ff;
	border:0px;
	transform: translateY(-95%);
	margin: 35px -9999rem;
    padding: 0.10rem 9999rem;
}
button{
	background-color:#0074D9;
	border-radius:10px;
	font-family:arial;
	border-color:transparent;
	padding:9px;
	font-size:18;
	width:150px;
	color: white;
	letter-spacing:1px;
	text-align: center;
	vertical-align: middle;
	line-height: 27px;
	display:inline-block;
	margin-left: 80px;
	margin-right: 80px;
}
button:visited{
	color:#0074D9;
}
button:hover{
	background-color:#0047b3;
}
button:active{
	color:#0047b3;
}

*{
    margin:0;
    padding:0;
}

#left {
	left:5% !important;
	bottom:50% !important;
	float:left;
	display: block;
    display: inline-block;
    width: 300px;
    border: 3px solid #0080ff;
    padding: 30px 25px;
    margin: 56px;
	vertical-align:-200%;
	font-family:arial !important;
	border-radius:25px;
	color:white;
	text-shadow: 2px 1px #0080ff;
	font-style: oblique;
	letter-spacing:1px;
	font-size:18;
	background: linear-gradient( rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.1) ), url('http://img.wallpaper.sc/desktop/images/5k/desktop-pc-5120x2880-wallpaper_00019.jpg');
    -webkit-background-size: cover;
    -moz-background-size:  cover;
    -o-background-size: cover;
    background-size: cover;
}


#middle {
	left: 38%;
	bottom:50%;
	display:block;
    display: inline-block;
    width: 300px;
	position: absolute !important;;
	top:30% !important;
    border: 3px solid #0080ff;
    padding: 30px;
    margin: 30px;
	margin-left:-20px !important;
	margin-right:-20px !important;
	font-family:arial;
	border-radius:25px;
	color:#ffffff;
	text-shadow: 2px 1px #0080ff;
	font-style: oblique;
	letter-spacing:1px;
	font-size:18;
	background: linear-gradient( rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.1) ), url('http://img.wallpaper.sc/desktop/images/5k/desktop-pc-5120x2880-wallpaper_00019.jpg');
    -webkit-background-size: cover;
    -moz-background-size:  cover;
    -o-background-size: cover;
    background-size: cover;
}
	
#right {
	float:right;
	right: 15% !important;
	bottom:50%;
	display: block;
    display: inline-block;
    width: 300px;
    border: 3px solid #0080ff;
    padding:30px;
    margin: 56px 25px -20px !important;
	vertical-align:-200%;
	font-family:arial;
	border-radius:25px;
	color:#ffffff;
	text-shadow: 2px 1px #0080ff;
	font-style: oblique;
	letter-spacing:1px;
	font-size:18;
	background: linear-gradient( rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.1) ), url('http://img.wallpaper.sc/desktop/images/5k/desktop-pc-5120x2880-wallpaper_00019.jpg');
    -webkit-background-size: cover;
    -moz-background-size:  cover;
    -o-background-size: cover;
    background-size: cover;
}

#allbox{
	left:5% !important;
	bottom:50% !important;
	vertical-align:-200% !important;
}

#left, #middle, #right{
	height: 130px
<!DOCTYPE>
<html>

<head>
    <title>Moj web</title>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="java2.js"></script>
    <script src="js/scripts.js"></script>
</head>
<link rel="stylesheet" href="style.css">

<body background="http://img.wallpaper.sc/desktop/images/5k/desktop-pc-5120x2880-wallpaper_00019.jpg">

    <ul>
        <li><a class="active" href="index.html">Home</a></li>
        <li><a href="news.html">News</a></li>
        <li><a href="contact.html">Contact</a></li>
        <li><a href="about.html">About</a></li>
    </ul>
    <br>
    <br>
<script>
$(document).ready(function(){
    $("#clicky").click(function(){
        $("#welcomeDiv").fadeToggle();
    });
});
</script>
<script>
$(document).ready(function(){
    $("#clicky2").click(function(){
        $("#welcomeDiver").fadeToggle();
    });
});
</script>

<script>
$(document).ready(function(){
    $("#clicky1").click(function(){
        $("#welcomeDiverer").fadeToggle();
    });
});
</script>

    <center>
        <div>
            <button id="clicky" style="margin-right: 75px">Press me!</button>
            <button id="clicky1" style="margin-right: 75px">Press me!</button>
            <button id="clicky2" style="margin-right: 75px">Press me!</button>
        </div>
    </center>
    <br>
    <br>

		<div id="welcomeDiv" style="display:none;">
			<div id="left">
				<p>Zdravo, ja sam Kenan!<br> Ovo je moja testna stranica na kojoj radim dosta kratko!<br> Na ovoj stranici mozete viditi HTML, CSS i JS jezike!<br>
				</p>
			</div>
		</div>
		<div id="welcomeDiver" style="display:none;">
			<div id="right">
				<p>Zdravo, ja sam Kenan!<br> Ovo je moja testna stranica na kojoj radim dosta kratko!<br> Na ovoj stranici mozete viditi HTML, CSS i JS jezike!<br>
				</p>
			</div>
		</div>
		<div id="welcomeDiverer" style="display:none;">
			<div id="middle">
				<p>Zdravo, ja sam Kenan!<br> Ovo je moja testna stranica na kojoj radim dosta kratko!<br> Na ovoj stranici mozete viditi HTML, CSS i JS jezike!<br>
				</p>
			</div>
		</div>
	
    <br>
</body>

</html>

2 个答案:

答案 0 :(得分:0)

您已margin : 56px;#left {}尝试相应更改

答案 1 :(得分:0)

它们与右边对齐太多是因为margin-right 25pxmargin: 56px 25px -20px !important;对应56px left-margin现在因为左边的div是25px right-margin屏幕,其中右侧div位于thr屏幕的margin:56px,距离左侧div较少,因此它看起来更加正确。更改为 body, html { height: 100%; margin: 0px; } body { background-size: auto 120%; background-repeat: no-repeat; background-position: right !important; } ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #0074D9; } li { float: left; } li a { display: block; text-align: center; padding: 14px 16px; text-decoration: none; color: white !important; font-family:arial; } li a:hover:not(.active) { background-color: #0047b3 !important; } .active { background-color:#0047b3; } a:link{ color:#0074D9; } a:visited{ color:#0074D9; } a:hover{ color:#001f3f; } a:active{ color:#001f3f; } hr{ height:3px; background-color:#0080ff; border:0px; transform: translateY(-95%); margin: 35px -9999rem; padding: 0.10rem 9999rem; } button{ background-color:#0074D9; border-radius:10px; font-family:arial; border-color:transparent; padding:9px; font-size:18; width:150px; color: white; letter-spacing:1px; text-align: center; vertical-align: middle; line-height: 27px; display:inline-block; margin-left: 80px; margin-right: 80px; } button:visited{ color:#0074D9; } button:hover{ background-color:#0047b3; } button:active{ color:#0047b3; } *{ margin:0; padding:0; } #left { left:5% !important; bottom:50% !important; float:left; display: block; display: inline-block; width: 300px; border: 3px solid #0080ff; padding: 30px 25px; margin: 56px; vertical-align:-200%; font-family:arial !important; border-radius:25px; color:white; text-shadow: 2px 1px #0080ff; font-style: oblique; letter-spacing:1px; font-size:18; background: linear-gradient( rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.1) ), url('http://img.wallpaper.sc/desktop/images/5k/desktop-pc-5120x2880-wallpaper_00019.jpg'); -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; } #middle { left: 38%; bottom:50%; display:block; display: inline-block; width: 300px; position: absolute !important;; top:30% !important; border: 3px solid #0080ff; padding: 30px; margin: 30px; margin-left:-20px !important; margin-right:-20px !important; font-family:arial; border-radius:25px; color:#ffffff; text-shadow: 2px 1px #0080ff; font-style: oblique; letter-spacing:1px; font-size:18; background: linear-gradient( rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.1) ), url('http://img.wallpaper.sc/desktop/images/5k/desktop-pc-5120x2880-wallpaper_00019.jpg'); -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; } #right { float:right; right: 15% !important; bottom:50%; display: block; display: inline-block; width: 300px; border: 3px solid #0080ff; padding:30px; margin: 56px; //new margin vertical-align:-200%; font-family:arial; border-radius:25px; color:#ffffff; text-shadow: 2px 1px #0080ff; font-style: oblique; letter-spacing:1px; font-size:18; background: linear-gradient( rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.1) ), url('http://img.wallpaper.sc/desktop/images/5k/desktop-pc-5120x2880-wallpaper_00019.jpg'); -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; } #allbox{ left:5% !important; bottom:50% !important; vertical-align:-200% !important; } #left, #middle, #right{ height: 130px; }到右边div将使其从两端对齐

<!DOCTYPE>
<html>

<head>
    <title>Moj web</title>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="java2.js"></script>
    <script src="js/scripts.js"></script>
</head>
<link rel="stylesheet" href="style.css">

<body background="http://img.wallpaper.sc/desktop/images/5k/desktop-pc-5120x2880-wallpaper_00019.jpg">

    <ul>
        <li><a class="active" href="index.html">Home</a></li>
        <li><a href="news.html">News</a></li>
        <li><a href="contact.html">Contact</a></li>
        <li><a href="about.html">About</a></li>
    </ul>
    <br>
    <br>
<script>
$(document).ready(function(){
    $("#clicky").click(function(){
        $("#welcomeDiv").fadeToggle();
    });
});
</script>
<script>
$(document).ready(function(){
    $("#clicky2").click(function(){
        $("#welcomeDiver").fadeToggle();
    });
});
</script>

<script>
$(document).ready(function(){
    $("#clicky1").click(function(){
        $("#welcomeDiverer").fadeToggle();
    });
});
</script>

    <center>
        <div>
            <button id="clicky" style="margin-right: 75px">Press me!</button>
            <button id="clicky1" style="margin-right: 75px">Press me!</button>
            <button id="clicky2" style="margin-right: 75px">Press me!</button>
        </div>
    </center>
    <br>
    <br>

		<div id="welcomeDiv" style="display:none;">
			<div id="left">
				<p>Zdravo, ja sam Kenan!<br> Ovo je moja testna stranica na kojoj radim dosta kratko!<br> Na ovoj stranici mozete viditi HTML, CSS i JS jezike!<br>
				</p>
			</div>
		</div>
		<div id="welcomeDiver" style="display:none;">
			<div id="right">
				<p>Zdravo, ja sam Kenan!<br> Ovo je moja testna stranica na kojoj radim dosta kratko!<br> Na ovoj stranici mozete viditi HTML, CSS i JS jezike!<br>
				</p>
			</div>
		</div>
		<div id="welcomeDiverer" style="display:none;">
			<div id="middle">
				<p>Zdravo, ja sam Kenan!<br> Ovo je moja testna stranica na kojoj radim dosta kratko!<br> Na ovoj stranici mozete viditi HTML, CSS i JS jezike!<br>
				</p>
			</div>
		</div>
	
    <br>
</body>

</html>
output = ['Mon', '5:00', 'pm', 'to', '12:00', 'am', 'Tue', '5:00', 'pm', 'to', '12:00', 'am']
date_list = []

# iterate over list (assuming list is consistent - with 6 values per section
for i in range(0, len(output), 6):
    # join the values on the list and append to date list
    date_list.append(' '.join(output[i:i+6]))

#print results
print(', '.join(date_list))