我已经用百分比定义了div的大小,但我不知道为什么它会自动减少。即使在像素中定义高度和宽度也无济于事。问题依然如故。请仔细阅读所有代码。这是代码。
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" import="java.sql.*, java.io.*"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>My Assessments</title>
<link rel="stylesheet" href="CSS/Styles.css" type="text/css">
<style>
li {
float: left;
font-size:20px;
}
#headul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #3d4e4a;
}
#bheadul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #23302d;
}
li a {
display: block;
color: white;
text-align: center;
padding: 16px 16px;
text-decoration: none;
}
button
{
float: left;
font-size:20px;
display: block;
color: white;
text-align: center;
padding: 16px 16px;
text-decoration: none;
}
li a:hover:not(.active) {
background-color: #111;
}
</style>
</head>
<body style="background:url(Images/Backgroud.jpg); background-size: 1370px 1000px;height:100%;width:100%;min-height: 100%;min-width: 100%;overflow-x: hidden;">
<div id="head" style="position:absolute; top:0; left:0;background-color:#ffffff;height:56px;">
<ul id="headul">
<li style="font-size:30px"><a href="Index.jsp">Quizilla</a></li>
<li style="float:right;"><a href="Contact.jsp">Contact Us</a></li>
<li style="float:right;"><a href="about.jsp">About Us</a></li>
<li style="float:right;"><a href="Features.jsp">Features</a></li>
<li style="float:right;"><a href="Index.jsp">Home</a></li>
</ul>
</div><br><br><br>
<div id="lowerhead" style="position:absolute;left:0;color:#ffffff;height:40px;">
<ul id="bheadul">
<% if((session.getAttribute("email"))!=null) { %>
<li style="float:left;"><a href="UserHome.jsp">My Home</a></li>
<li><a href="UserProfile.jsp">My Profile</a></li>
<li><a href="UserScores.jsp">My Scores</a></li>
<li><a href="Assessments.jsp">Assessments</a></li>
<%} %>
<% if((session.getAttribute("email"))==null)
response.sendRedirect("Login.jsp");
%>
<%for(int i=0;i<67;i++)
out.println(" "); %>
<li style="float:right;"><a href="Index.jsp?logout=success">Logout</a></li>
<li style="float:right;"><a href="ChangePassword.jsp">Change Password</a></li>
</ul>
</div><br><br><br><br><br><br>
<div style="height:730px;width:1143px;background-color:#f7fcfa;margin-left: auto; margin-right: auto;margin-top:auto;box-shadow: 10px 10px 5px #888888;">
<div style="float:left;align-content: center;height:8%;width:25%;background-color:#E7F5F1"><br>
<h1 style="text-align:center;margin-top:auto;">My Assessments</h1>
</div>
<div style="height:8%;width:74.8%;float:right; border:1px solid #000000">
<form name="create" action="CreateQuiz.jsp">
<div style="height:100%; width:80%; border:1px solid #000000;float:left;margin-top:auto;">
<input style="margin-top:10px;font-size:16px;float:right;" type="text" name="Test_Name" placeholder="Test Title" required/></div>
<div style="height:100%; width:19.5%;float:right; border:1px solid #000000;margin-top:auto;">
<input type="submit"style="float:right;"></div>
</form>
</div>
<div style="height:8%;width:74.8%;float:right; border:1px solid #000000">
<div style="float:left;height:100%;width:50%;"><h3>Test Name</h3></div>
<div style="float:left;height:100%;width:24.5%;"><h3>Number of Questions</h3></div>
<div style="float:left;height:100%;width:24.5%;"><h3>Maximum Marks</h3></div>
</div>
<%getTest(session,out); %>
</div>
<%!
public static void getTest(HttpSession session,JspWriter out)
{
String username = (String)session.getAttribute("email");
try{
Class.forName("com.mysql.jdbc.Driver");
//creating connection with the database
Connection con=DriverManager.getConnection
("jdbc:mysql://localhost:3306/quizilla","root","manish123");
String query="select test_name, number, max_marks from test_table where email='"+username+"'";
PreparedStatement ps =con.prepareStatement(query);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
String test_name = rs.getString("test_name");
int number= rs.getInt("number");
int max_marks=rs.getInt("max_marks");
String div="<div style= 'height:8%;width:74.8%;float:right;'>";
out.println(div);
String div1="<div style= 'float:left;height:100%;width:50%;'>";
String div2="<div style= 'float:left;height:100%;width:24.5%;'>";
String div3="<div style= 'float:left;height:100%;width:24.5%;'>";
String field1="<pre style='font-size:18px'>"+test_name+"</pre>";
String field2="<pre style='font-size:18px'> "+number+"</pre>";
String field3="<pre style='font-size:18px'> "+max_marks+"</pre>";
out.println(div1);
out.println(field1+"</div>");
out.println(div2);
out.println(field2+"</div>");
out.println(div3);
out.println(field3+"</div></div><br><br>");
}
}
catch(Exception e)
{}
}
%>
</body>
</html>
请告诉我该怎么做?
答案 0 :(得分:0)
当您将标记嵌套在另一个标记内时,“%”值引用外部标记(即嵌套目标标记)
如果我理解正确,这可能会解决问题。