Commit 6e5b9b0f by luyt

feat:sell car site

0 parents
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
* {
padding: 0;
margin: 0;
}
html,
body {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
}
#container {
display: flex;
justify-content: space-between;
align-items: center;
position: fixed;
left: 0;
top: 0;
width: 563px;
height: 333px;
padding: 20px 27px;
box-sizing: border-box;
background-color: #361a43;
border-radius: 5px;
overflow: hidden;
/* background-image: url(img/auction.svg);
background-size: 100% 100%; */
}
#container:hover {
border: #00cdcd 2px solid;
}
.auction{
width: 100%;
height: 100%;
}
/* #container .left {
margin-left: 14px;
}
.text .p1 {
font-size: 30px;
color: #E3FE03;
}
.text .p2 {
font-size: 40px;
color: #FFFFFF;
}
.text1 {
margin-top: 50px;
margin-bottom: 36px;
}
.tip {
font-size: 16px;
color: #B2B2BF;
}
#container .right {
width: 231px;
height: 293px;
background: url(img/auction.png);
} */
.wrap {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>
</head>
<body id="body">
<iframe src="http://auction.autostreets.com/screen/27545" width="100%" height="100%" scrolling="no" id="website"
frameborder="0"></iframe>
<div class="wrap"></div>
<div id="container">
<img class="auction" src="img/auction.png" >
<!-- <div class="left">
<div class="text">
<div class="p1">竞拍信息</div>
<div class="p2">全透明</div>
</div>
<div class="text text1">
<div class="p1">竞拍信息</div>
<div class="p2">全透明</div>
</div>
<div class="tip">优·质·好·车 低·价·起·拍</div>
</div>
<div class="right"></div> -->
</div>
<script>
//需要调整尺寸的div
let c = document.getElementById('container')
// body监听移动事件
document.getElementById('body').addEventListener('mousemove', move)
// 鼠标按下事件
c.addEventListener('mousedown', down)
// 鼠标松开事件
document.getElementById('body').addEventListener('mouseup', up)
// 是否开启尺寸修改
let resizeable = false
// 鼠标按下时的坐标,并在修改尺寸时保存上一个鼠标的位置
let clientX, clientY
// div可修改的最小宽高
let minW = 8,
minH = 8
// 鼠标按下时的位置,使用n、s、w、e表示
let direc = ''
// 鼠标松开时结束尺寸修改
function up() {
resizeable = false
// document.body.removeEventListener('mousemove',move,false);
// document.body.removeEventListener('mouseup',up,false);
}
// 鼠标按下时开启尺寸修改
function down(e) {
let d = getDirection(e)
// 当位置为四个边和四个角时才开启尺寸修改
if (d !== '') {
resizeable = true
direc = d
clientX = e.clientX
clientY = e.clientY
}
}
// 鼠标移动事件
function move(e) {
let d = getDirection(e)
let cursor
// if (d === '') cursor = 'default';
if (d === '') cursor = 'move';
else cursor = d + '-resize';
// 修改鼠标显示效果
c.style.cursor = cursor;
// 当开启尺寸修改时,鼠标移动会修改div尺寸
if (resizeable) {
// 鼠标按下的位置在右边,修改宽度
if (direc.indexOf('e') !== -1) {
c.style.width = Math.max(minW, c.offsetWidth + (e.clientX - clientX)) + 'px'
clientX = e.clientX
}
// 鼠标按下的位置在上部,修改高度
if (direc.indexOf('n') !== -1) {
return
c.style.height = Math.max(minH, c.offsetHeight + (clientY - e.clientY)) + 'px'
clientY = e.clientY
}
// 鼠标按下的位置在底部,修改高度
if (direc.indexOf('s') !== -1) {
c.style.height = Math.max(minH, c.offsetHeight + (e.clientY - clientY)) + 'px'
clientY = e.clientY
}
// 鼠标按下的位置在左边,修改宽度
if (direc.indexOf('w') !== -1) {
return
c.style.width = Math.max(minW, c.offsetWidth + (clientX - e.clientX)) + 'px'
clientX = e.clientX
}
}
}
// 获取鼠标所在div的位置
function getDirection(ev) {
let xP, yP, offset, dir;
dir = '';
xP = ev.offsetX;
yP = ev.offsetY;
offset = 10;
if (yP < offset) dir += 'n';
else if (yP > c.offsetHeight - offset) dir += 's';
if (xP < offset) dir += 'w';
else if (xP > c.offsetWidth - offset) dir += 'e';
return dir;
}
// 拖拽
//定义元素初始位置
var eleP = {
left: 0,
top: 0
};
//定义鼠标初始位置
var startP = {
left: 0,
top: 0
};
c.onmousedown = function(event) {
if (resizeable) return
event = event || window.event;
//元素初始位置
eleP.left = c.offsetLeft;
eleP.top = c.offsetTop;
//鼠标初始位置
startP.left = event.clientX;
startP.top = event.clientY;
//c.onmousemove
document.onmousemove = function(event) {
event = event || window.event;
//鼠标最终位置
var endP = {
left: 0,
top: 0
};
endP.left = event.clientX;
endP.top = event.clientY;
//鼠标距离差
var disX = endP.left - startP.left;
var disY = endP.top - startP.top;
//确定元素位置
c.style.left = disX + eleP.left + 'px';
c.style.top = disY + eleP.top + 'px';
};
document.onmouseup = function() {
document.onmousemove = null;
document.onmouseup = null;
};
//禁止系统默认行为
return false;
};
//获取url参数
function getUrlParams(key){
var reg = new RegExp(key + '=([^&]*)');
var result = location.href.match(reg);
return result ?decodeURI(result[1]):null;
}
let id = getUrlParams('id')
id = id?id:27545
let websrc = 'http://auction.autostreets.com/screen/'+id
let website = document.getElementById('website')
website.setAttribute('src',websrc)
</script>
</body>
</html>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!