2016-04-20 10 views
1

Ich habe die Größe der Divs in Prozent definiert, aber ich weiß nicht, warum es automatisch reduziert wird. Selbst die Definition der Höhe und Breite in den Pixeln hilft nicht. Das Problem bleibt gleich. Bitte gehen Sie den ganzen Code durch. Hier ist der Code.Warum div's Größe automatisch reduziert, auch wenn ich die Größe gegeben habe

<%@ 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> 
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
        <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> 
        &nbsp; 
       </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("&nbsp;"); %> 
      <li style="float:right;"><a href="Index.jsp?logout=success">Logout</a></li>&nbsp; 
      <li style="float:right;"><a href="ChangePassword.jsp">Change Password</a></li>&nbsp; 
     </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> 

Bitte sagen Sie mir, was zu tun ist?

+0

Sie verwenden zwei separate Divs innerhalb des Form-Tags. Das verursacht all die Probleme. –

+0

kann ich Div in Form-Tag nicht verwenden? –

+0

Ja können Sie. Aber dieses divs Verhalten. Ich habe alles versucht, um dein Problem zu lösen. Es funktioniert nicht. –

Antwort

0

Wenn Sie nisten in einem anderen einen Tag, bezieht sich der „%“ Wert auf äußereen Tag (das den Ziel-Tag nistet)

Wenn ich es richtig verstanden hat, das Problem lösen könnte.

+0

Ja, Sie verstehen absolut richtig, aber wie Sie sehen können, habe ich die Höhe von div 100% gegeben, deshalb frage ich –

+0

Wenn Sie sagen _ "es wird automatisch reduziert" _, meinst du, dass es die Größe ändert wenn skalierst du den Bildschirm? –

+0

Nein, ich meine, ich habe die divs Größe gegeben angenommen 100px und die Größe des Textfelds wenn 50px, die div's Größe wird automatisch 50px obwohl im Code ist es 100px –

Verwandte Themen