最近我在做一个网页,结果,出现了以下问题
<%@ page language="java" import="java.util.*" pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
int port=request.getServerPort();
if(port==80){
basePath=request.getScheme()+"://"+request.getServerName()+path;
}else{
basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
}
request.setAttribute("basePath", basePath);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body >
<div class='ban' style="background-position: center;height:100%;width:100%;background-size: cover;
background-repeat: no-repeat;background-image:url('${basePath}/img/pink.jpg')" >
<div>
<div style="position: absolute;left:24px;display: inline-block">
选择城市分站
<select onchange="window.open(this.options[this.options.selectedIndex].value);">
<option value="选择城市"></option>
<option value="${basePath}/Shanghai.jsp">上海</option>
<option value="${basePath}/Hangzhou.jsp">杭州</option>
<option value="${basePath}/Nanjing.jsp">南京</option>
<option value="${basePath}/Hefei.jsp">合肥</option>
<option value="${basePath}/Suzhou.jsp">苏州</option>
<option value="${basePath}/Ningbo.jsp">宁波</option>
<option value="${basePath}/Wenzhou.jsp">温州</option>
<option value="${basePath}/Jinhua.jsp">金华</option>
<option value="${basePath}/Yangzhou.jsp">扬州</option>
<option value="${basePath}/Wuxi.jsp">无锡</option>
</select>
</div>
<div style="position: absolute;right:24px;display:inline-block;vertical-align: top">
<a href="${basePath}/Login.jsp">登录</a>
<a href="${basePath}/Register.jsp">注册</a>
</div>
</div>
<div class="ben" style="width: window.width;height=400px">
<img src="${basePath}/img/ee.jpg"></img>
</div>
</body>
</html>
看看代码有什么问题,为什么会这样。
img
没有设置宽度,会根据图片本身的大小渲染,需要设置100%
,而且不能在css
上写js
语法
width:100%试试