1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
| <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>JS Bin</title>
<style>
.slide{
position: relative;
overflow: hidden;
user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
margin-top: 5px;
border: 1px solid rgb(240, 240, 240);
}
.slide > div {
position: absolute;
-ms-user-select: none;
user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
border: 1px solid rgb(230, 230, 230);
}
#fond5,#fond8 {
border: 1px solid rgb(240, 240, 240);
border-radius: 10px;
background: linear-gradient(to bottom, rgba(220, 220, 220, 0) 44%, rgba(33, 180, 226, 1) 53%, rgba(220, 220, 220, 0) 63%);
margin-top: 5px;
}
#fond5.actif ,#fond8.actif{
border: 1px solid rgb(250, 250, 250);
border-radius: 10px;
background: linear-gradient(to bottom, rgba(255, 255, 255, 1) 44%, rgba(255, 0, 255, 1) 53%, rgba(255, 255, 255, 1) 63%);
box-shadow: 0 0 1em #BDBDBD inset;
margin-top: 5px;
}
#fond5 > div ,#fond8 > div{
background: linear-gradient(to bottom, rgba(220, 227, 145, 0.1) 0%, rgba(97, 196, 25, 1) 50%, rgba(180, 227, 145, 1) 100%);
}
#fond5.actif > div,#fond8.actif > div{
background: linear-gradient(to bottom, rgba(240, 240, 0, 1) 0%, rgba(255, 50, 0, 1) 50%, rgba(240, 240, 0, 1) 100%);
}
#fond6 {
border: 1px solid rgb(240, 240, 240);
border-radius: 10px;
background: linear-gradient(to bottom, rgba(255, 255, 255, 1) 44%, rgba(255, 0, 255, 1) 53%, rgba(255, 255, 255, 1) 63%);
margin-top: 5px;
}
#fond6.actif {
border: 1px solid rgb(250, 220, 0);
border-radius: 10px;
background: linear-gradient(to bottom, rgba(255, 255, 255, 1) 44%, rgba(255, 0, 255, 1) 53%, rgba(255, 255, 255, 1) 63%);
box-shadow: 0 0 1em rgb(255, 100, 0) inset;
margin-top: 5px;
}
#fond6 > div {
background: linear-gradient(to bottom, rgba(80, 134, 196, 1) 1%, rgba(62, 92, 201, 1) 43%, rgba(62, 92, 201, 1) 56%, rgba(80, 134, 196, 1) 100%);
}
#fond6.actif > div {
background: linear-gradient(to bottom, rgba(240, 240, 0, 1) 0%, rgba(255, 50, 0, 1) 50%, rgba(240, 240, 0, 1) 100%);
}
#fond7 {
border: 1px solid rgb(245, 245, 245);
border-radius: 10px;
background: linear-gradient(to bottom, rgba(255, 255, 255, 0.1) 44%, rgba(0, 255, 0, 1) 53%, rgba(255, 255, 255, 1) 63%);
margin-top: 5px;
}
#fond7.actif {
border: 1px solid rgb(250, 250, 250);
border-radius: 10px;
background: linear-gradient(to bottom, rgba(255, 255, 255, 1) 44%, rgba(255, 0, 0, 1) 53%, rgba(255, 255, 255, 1) 63%);
box-shadow: 0 0 1em #BDBDBD inset;
margin-top: 5px;
}
#fond7 > div {
box-shadow: 0 0 1em #58D3F7 inset;
background-color: rgb(245, 245, 245);
}
#fond7.actif > div {
box-shadow: 0 0 1em #6E6E6E inset;
background-color: rgb(245, 245, 245);
}
</style>
<script type= "text/javascript">
var LrG;
var Crs;
var oX;
var newX;
var Mx;
var Dv;
var dragg;
function Start(event) {
console.log(event.target.id);
Crs = event.target;
dragg = Crs.parentElement;
dragg.classList.add ("actif");
LrG = Crs.parentElement.offsetWidth - (Crs.offsetWidth / 2);
Dv = (LrG - (Crs.offsetWidth / 2)) / 100;
oX = event.clientX + (document.documentElement.scrollLeft + document.body.scrollLeft);
Mx = oX - Crs.offsetLeft;
dragg.addEventListener("mousemove", dragging, false);
dragg.addEventListener("mouseup", relache, false);
dragg.addEventListener("mouseleave", relache, false);
}
function dragging(event) {
newX = event.clientX + (document.documentElement.scrollLeft + document.body.scrollLeft);
console.log("deplacement " + newX);
var posX = newX - Mx;
if (posX < 0) {
posX = 0;
}
if (posX > LrG - (Crs.offsetWidth / 2)) {
posX = LrG - (Crs.offsetWidth / 2);
}
Crs.style.position = "absolute";
Crs.style.left = posX + "px";
document.getElementById("res").innerHTML = Crs.id + " : " + Math.round(Crs.offsetLeft / Dv);
}
function relache(event) {
dragg.removeEventListener("mousemove", dragging);
dragg.removeEventListener("mouseup", relache);
dragg.removeEventListener("mouseleave", relache);
dragg.classList.remove ("actif");
}
function ajoute() {
var messlides = document.querySelectorAll(".slide");
for (var i = 0; i < messlides.length; i++) {
messlides[i].firstElementChild.addEventListener("mousedown", Start, false);
}
}
</script>
</head>
<body>
<div id="conteneur1" style="position:absolute;height:200px;left:28px;width:350px;border:2 solid red;">
des slides pas comme les autres
<p id ="res">position</p>
<br/><br/>
<div id="fond5" class="slide" style="width:300px;height:26px;" >
<div id="Crs5" class="cur" style="top:0px;width:26px;height:26px;border-radius:8px;" ></div>
</div>
<div id="fond6" class="slide" style="width:300px;height:26px;" >
<div id="Crs6" class="cur" style="top:7px;width:26px;height:14px;border-radius:8px;"></div>
</div>
<div id="fond7" class="slide" style="width:300px;height:26px;" >
<div id="Crs7" class="cur" style="top:0px;width:26px;height:26px;border-radius:50%;"></div>
</div>
<div id="fond8" class="slide" style="width:300px;height:26px;" >
<div id="Crs8" class="cur" style="top:0px;width:26px;height:26px;border-radius:50%;"></div>
</div>
</div>
<script> ajoute();</script>
</body>
</html> |
Partager