天天看點

html 一鍵複制 ios,相容安卓和ios實作一鍵複制内容到剪切闆

js相容安卓和ios實作粘貼闆一鍵複制

color: #000;

background: #fff;

overflow-y: scroll;-webkit-text-size-adjust: 100%;-ms-text-size-adjust: 100%;

}

html*{

outline:0;-webkit-text-size-adjust: none;-webkit-tap-highlight-color: transparent

}*{

margin:0;

padding:0}

.content {78.7%;

height:11.093rem;

margin:0auto;

background: url('./xxxxxx.png');

background-size: 100% 100%;

margin-top: 20%;

}

.onebox{

height:8.907rem;

}

.midtext{

font-family: PingFangSC-Regular;

font-size: 12px;

color: #4FA3FF;

letter-spacing: 0;

text-align: left;66%;

padding-top: 8.0rem;

margin:0auto;

}

.bottbox{

text-align: center;

font-size: 0;

margin-top: 0.693rem;

}

.one-copy{3.467rem;

height:0.853rem;

}#message{27%;

height:0.8rem;

line-height: 0.8rem;

bottom:50%;

font-size: 12px;

color: #fff;

z-index: 99;

box-shadow: 0 1px 14px rgba(0,0,0,.24);

opacity:0;

visibility: hidden;-webkit-transform: translateX(-50%);-ms-transform: translateX(-50%);

transform: translateX(-50%);

text-align: center;

border-radius: 0.8rem;

}

#message.show {

visibility: visible;

}

#message {

position:fixed;

background: rgba(0,0,0,.6);

left:50%;

}

#msgTxt{

line-height:1.55rem;

height:3.1rem;

}

.show {

display: block!important;

}

https://ahhahahahhahahah

html 一鍵複制 ios,相容安卓和ios實作一鍵複制内容到剪切闆

//相容安卓和ios實作剪切闆複制的方法

function copy() {var message="https://ajskajskajskajskjaskajksjka";var input = document.createElement("input");

input.value=message;

document.body.appendChild(input);

input.select();

input.setSelectionRange(0, input.value.length), document.execCommand('Copy');

document.body.removeChild(input);//一鍵複制按鈕變淺

document.querySelector("#one-copy").style.opacity='0.5';//複制成功提示

toast('複制成功');

}//彈窗元件

function toast(message) {vartimer;

document.querySelector("#message").style.opacity='1';

document.getElementById('mytext').innerHTML=message;

clearTimeout(timer);

timer= setTimeout( ()=>{

document.querySelector("#message").style.opacity='0';

},2000);

}