前端开发中--点击图片放大效果的实现

2021年9月28日 18:28 by wst

bootstrap

最近在做网站的时候,想让用户点击缩略图时可以放大显示。自己写又麻烦,于是找了第三方的插件,实现方法如下:

下载Bootstrap-viewer库

下载地址:https://github.com/movingheart/bootstrap-viewer

大家可以用https的方式拉取,这样会更方便一些,命令如下:

git clone https://github.com/movingheart/bootstrap-viewer.git

在网页中配置库

网页内容如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
    <style>
        .viewer{
            width: auto;
            height: 200px;
        }
        .container{
            margin-top: 200px;
        }
    </style>
</head>
<body>

    <div class="container">
        <div class="row">
            <img src="./images/peiqi_s.jpg" data-original="./images/peiqi_l.jpg" class="img-reponsive col-md-6 viewer"/>
            <img src="./images/qiaozhi_s.jpg" data-original="./images/qiaozhi_l.jpg"  class="img-reponsive col-md-6 viewer"/>
        </div>

    </div>

    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.js"></script>
    <script src="../dist/bootstrap.viewer.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('.viewer').bootstrapViewer({
                src: "data-original"
            });//The default image source file path is the src attribute of the img tag.
        })
    </script>
</body>
</html>

注意点

1. 在引入外部文件的时候的顺序:css文件在head中引入,js文件的引入请按照代码中的顺序;

2. 32-38行中的作用是:

    *  找class中有viewer的元素,附加上bootstrapViewer方法,即点击图片放大。

    *  35行的作用时,点击时放大的图片从元素的data-original属性中取,如果不传这个参数,则src取;

 

后话

刚开始在网上找的都是viewer.js的用法,奈何麻烦,代码又多。

况且我用的是bootstrap框架,所以用bootstrap-viewer库啦。

但是呢,用法不全面,最后经过探索,发现可以定制显示用的属性。

于是fork了仓库,添加了例子,以方便后来人。


Comments(124) Add Your Comment

Nbvvvr
atorvastatin cheap <a href="https://lipiws.top/">lipitor over the counter</a> atorvastatin 80mg ca
Bnxemq
ciprofloxacin oral - <a href="https://metroagyl.top/">buy cipro</a> brand augmentin
Umkonf
cipro generic - <a href="https://cipropro.top/bactrimos/">bactrim oral</a> buy augmentin 1000mg pills
Djyvjt
purchase flagyl sale - <a href="https://metroagyl.top/">metronidazole pill</a> azithromycin 500mg pills
Uschkp
buy ciprofloxacin 500mg for sale - <a href="https://septrim.top/trimox/">amoxicillin brand</a> erythromycin for sale
Mkxwpk
valtrex 500mg uk - <a href="https://gnantiviralp.com/diltiazem/">diltiazem buy online</a> order acyclovir 800mg generic
Olyxxg
price of stromectol - <a href="https://keflexin.top/tetracycline/">order sumycin</a> purchase tetracycline online
Xkupvb
order flagyl 200mg generic - <a href="https://metroagyl.top/cefaclor/">order cefaclor 500mg sale</a> zithromax price
Hztgpy
buy acillin pills for sale <a href="https://ampiacil.top/doxycyclineantb/">how to buy doxycycline</a> cheap amoxicillin pill
Vrmyrc
buy lasix without prescription - <a href="https://antipathogenc.com/capoten/">buy capoten 120mg without prescription</a> capoten 120mg us
Utxeqc
buy retrovir 300 mg sale - <a href="https://canadiangnp.com/avapro/">generic irbesartan 150mg</a> allopurinol tablet
Gavdsv
glucophage 1000mg sale - <a href="https://gnantiacidity.com/lincocin/">order lincocin generic</a> oral lincomycin 500mg
Vbqeco
clozaril pill - <a href="https://genonlinep.com/frumil/">frumil usa</a> famotidine 40mg sale
Szdmec
buy seroquel generic - <a href="https://gnkantdepres.com/zoloft/">zoloft 50mg uk</a> cheap eskalith
Dkipnt
buy hydroxyzine 25mg sale - <a href="https://antdepls.com/pamelor/">order nortriptyline 25mg</a> generic amitriptyline 25mg
Vqqgpp
purchase anafranil sale - <a href="https://antdeponline.com/asendin/">order amoxapine 50 mg online cheap</a> doxepin 25mg cost
Vbktct
how to get amoxicillin without a prescription - <a href="https://atbioxotc.com/erythromycin/">generic erythromycin 250mg</a> buy cipro pills
Boasdy
buy clavulanate no prescription - <a href="https://atbioinfo.com/">order augmentin 1000mg generic</a> ciprofloxacin 1000mg ca
Evveqz
buy cleocin 300mg online - <a href="https://cadbiot.com/cefixime/">buy cefixime 100mg generic</a> buy chloramphenicol tablets
Sznkcn
purchase zithromax without prescription - <a href="https://gncatbp.com/emetronidazole/">flagyl order online</a> ciplox for sale online
Hicezk
ventolin 2mg for sale - <a href="https://antxallergic.com/oiphenergan/">promethazine 25mg generic</a> buy cheap theo-24 Cr
Sajgcz
stromectol 3 mg price - <a href="https://antibpl.com/rferyc/">eryc 250mg usa</a> cefaclor 500mg usa
Uycvfm
buy clarinex 5mg - <a href="https://rxtallerg.com/ventolinpill/">albuterol 4mg uk</a> albuterol 4mg brand
Rxuyhv
buy methylprednisolone us - <a href="https://ntallegpl.com/getazelastine/">order astelin 10 ml online</a> order astelin 10ml generic
Wslkga
order micronase 5mg generic - <a href="https://prodeprpl.com/">order micronase 5mg online cheap</a> cost dapagliflozin 10mg
Bhwjpp
buy prandin 2mg sale - <a href="https://depressinfo.com/jardiance25/">empagliflozin online buy</a> buy jardiance 10mg
Jzejlz
glucophage 500mg generic - <a href="https://arxdepress.com/">metformin 1000mg over the counter</a> order acarbose 50mg without prescription
Ufusfl
terbinafine online - <a href="https://treatfungusx.com/fulvicin250mg/">order fulvicin without prescription</a> grifulvin v online buy
Rbhygt
buy semaglutide medication - <a href="https://infodeppl.com/ddavpspray/">buy DDAVP online cheap</a> DDAVP sale
Kytkot
nizoral 200 mg usa - <a href="https://antifungusrp.com/">cost nizoral 200 mg</a> itraconazole uk
Atfhfh
digoxin online order - <a href="https://blpressureok.com/trandate100/">trandate 100 mg generic</a> furosemide uk
Iwkgqy
buy generic famvir 500mg - <a href="https://amvinherpes.com/gnvalaciclovir/">buy valcivir 1000mg</a> oral valaciclovir 500mg
Flfzbr
hydrochlorothiazide where to buy - <a href="https://norvapril.com/lisinopril/">order lisinopril 5mg generic</a> brand bisoprolol 5mg
Qernel
metoprolol tablet - <a href="https://bloodpresspl.com/">lopressor oral</a> order adalat pills
Gtzwrf
generic nitroglycerin - <a href="https://nitroproxl.com/catapres/">clonidine 0.1 mg drug</a> order diovan 80mg pill
Xbffuf
rosuvastatin online message - <a href="https://antcholesterol.com/">rosuvastatin online comfortable</a> caduet buy curve
Hvirko
zocor case - <a href="https://canescholest.com/">zocor wine</a> lipitor city
Picsmk
viagra professional online faint - <a href="https://edsildps.com/superkamagra/">kamagra fright</a> levitra oral jelly online believe
Csmgff
cenforce online foreign - <a href="https://xcenforcem.com/tadaciptadalafil/">tadalafil ca</a> brand viagra online stop
Slfpnu
priligy coach - <a href="https://promedprili.com/">priligy sneak</a> cialis with dapoxetine item
Cnzrfn
brand cialis stool - <a href="https://probrandtad.com/">brand cialis genuine</a> penisole inquiry
Vevnev
cialis soft tabs online horizon - <a href="https://supervalip.com/cialisoraljelly/">cialis oral jelly pills something</a> viagra oral jelly book
Brymth
brand cialis dare - <a href="https://probrandtad.com/tadorapills/">tadora crouch</a> penisole well
Pcwbor
cialis soft tabs online lover - <a href="https://supervalip.com/cialisoraljelly/">cialis oral jelly sufficient</a> viagra oral jelly tick
Pcujnj
cenforce fit - <a href="https://xcenforcem.com/cialistadalafil/">tadalafil pill</a> brand viagra pills sudden
Bxcbjr
acne medication crown - <a href="https://placnemedx.com/">acne treatment sweep</a> acne medication brood
Xyksua
asthma medication justice - <a href="https://bsasthmaps.com/">inhalers for asthma virtue</a> asthma medication starve
Llpezi
uti antibiotics lash - <a href="https://amenahealthp.com/">treatment for uti upstairs</a> uti medication breath
Thvudw
prostatitis medications mail - <a href="https://xprosttreat.com/">prostatitis pills flood</a> prostatitis medications walk
Vjffud
valtrex school - <a href="https://gnantiviralp.com/">valacyclovir pills gift</a> valtrex bigger
Tcfmkb
loratadine medication consideration - <a href="https://clatadine.top/">claritin stool</a> claritin delicate
Fxdesn
loratadine medication compliment - <a href="https://clatadine.top/">loratadine medication quite</a> claritin regard
Yghwdj
priligy nothing - <a href="https://prilixgn.top/">dapoxetine breathe</a> dapoxetine glimmer
Iodham
promethazine bronze - <a href="https://prohnrg.com/">promethazine definite</a> promethazine noon
Gcbvpk
ascorbic acid steel - <a href="https://ascxacid.com/">ascorbic acid tongue</a> ascorbic acid milk
Nbubgb
florinef pills render - <a href="https://gastroplusp.com/nexesomeprazole/">esomeprazole grateful</a> prevacid pills cigar
Xtijtw
biaxin pills discover - <a href="https://gastropls.com/gncytotec/">cytotec shed</a> cytotec pills screen
Qzdwzw
order dulcolax - <a href="https://gastroinfop.com/liv52/">buy liv52 generic</a> brand liv52
Ezatim
rabeprazole us - <a href="https://gastrointesl.com/metoclopramide/">metoclopramide 10mg price</a> motilium 10mg without prescription
Vprros
bactrim 480mg price - <a href="https://tobmycin.com/">purchase tobramycin sale</a> brand tobra
Rovwsh
eukroma cost - <a href="https://dupsteron.com/">buy cheap duphaston</a> order dydrogesterone 10 mg online cheap
Fojfob
buy generic dapagliflozin 10mg - <a href="https://forpaglif.com/">forxiga 10mg drug</a> buy acarbose 50mg for sale
Klmsvu
fulvicin 250 mg brand - <a href="https://gemfilopi.com/">lopid online order</a> buy generic lopid over the counter
Uhncma
order vasotec 10mg without prescription - <a href="https://vasolapril.com/">order enalapril generic</a> where to buy zovirax without a prescription
Nlefwt
dramamine uk - <a href="https://actodronate.com/">order risedronate 35 mg online</a> actonel 35mg generic
Jklqwg
buy piroxicam 20mg online - <a href="https://rivastilons.com/">buy exelon generic</a> buy cheap generic exelon
Eyzyqr
etodolac buy online - <a href="https://cilosetal.com/">brand cilostazol</a> buy pletal 100 mg
Dorpgd
hydrea online - <a href="https://hydroydrinfo.com/methocarbamol/">order generic robaxin</a> methocarbamol for sale online
Pfpsbj
buy piracetam without prescription - <a href="https://nootquin.com/praziquantel/">praziquantel 600mg generic</a> sinemet 20mg us
Rakmpq
norpace buy online - <a href="https://anorpica.com/">norpace for sale</a> chlorpromazine online buy
Aamvpa
depakote cheap - <a href="https://adepamox.com/mefloquine/">buy mefloquine tablets</a> buy topiramate 200mg pills
Jhuhby
purchase cytoxan pill - <a href="https://cycloxalp.com/stavudine/">purchase stavudine generic</a> buy vastarel online cheap
Yslhqg
order spironolactone 100mg generic - <a href="https://aldantinep.com/">spironolactone 100mg cost</a> revia over the counter
Tuyuxd
zofran oral - <a href="https://azofarininfo.com/selegiline/">cheap eldepryl generic</a> ropinirole for sale
Emrecv
flexeril 15mg for sale - <a href="https://abflequine.com/donepezil/">order aricept generic</a> order vasotec 10mg online
Hisdaq
order durex gel cheap - <a href="https://xalaplinfo.com/">order durex gel online</a> buy latanoprost medication
Ojosgz
buy ascorbic acid 500 mg without prescription - <a href="https://mdacidinfo.com/ferroussulfate/">order generic ferrous</a> oral prochlorperazine
Ndwocr
arava pills - <a href="https://infohealthybones.com/risedronate/">risedronate 35 mg cost</a> cheap cartidin pill
Smonri
cheap minoxidil generic - <a href="https://mdacidinfo.com/dutasteride/">dutas usa</a> propecia 5mg over the counter
Ajclsl
atenolol 100mg oral - <a href="https://heartmedinfox.com/">purchase tenormin generic</a> buy cheap generic carvedilol
Hjxudu
buy calan online - <a href="https://infoheartdisea.com/atenolol/">buy tenoretic generic</a> buy tenoretic pills for sale
Ftposc
order atorlip for sale - <a href="https://infoxheartmed.com/">cheap atorlip generic</a> bystolic 20mg cost
Ytgkyh
buy lasuna - <a href="https://infoherbalmz.com/himcolin/">buy himcolin pill</a> himcolin drug
Ftsjki
how to buy gasex - <a href="https://herbalinfomez.com/ashwagandha/">ashwagandha over the counter</a> buy diabecon medication
Feiyky
speman order - <a href="https://spmensht.com/himplasia/">order himplasia online</a> order fincar online
Kywijz
buy noroxin pills - <a href="https://gmenshth.com/flutamide/">buy eulexin for sale</a> buy confido generic
Sepnww
buy finasteride generic - <a href="https://finmenura.com/kamagra/">sildenafil 100mg us</a> alfuzosin 10 mg for sale
Cvpizu
cost terazosin 1mg - <a href="https://hymenmax.com/dutasteride/">avodart sale</a> dapoxetine drug
Zaljnf
duphalac where to buy - <a href="https://duphalinfo.com/">lactulose over the counter</a> buy generic betahistine over the counter
Piwceq
trileptal uk - <a href="https://trileoxine.com/">order oxcarbazepine 600mg for sale</a> buy cheap synthroid online
Lqodzy
imusporin oral - <a href="https://asimusxate.com/gloperba/">buy generic colcrys online</a> colchicine us
Twvtcd
deflazacort drug - <a href="https://lazacort.com/">order deflazacort online</a> alphagan cost
Welyrb
cost besifloxacin - <a href="https://besifxcist.com/">buy besifloxacin online cheap</a> sildamax for sale online
Wvlzle
gabapentin online buy - <a href="https://aneutrin.com/">gabapentin without prescription</a> azulfidine 500mg for sale
Wqneps
probalan price - <a href="https://bendoltol.com/carbamazepine/">order carbamazepine generic</a> order generic tegretol
Nanxji
cost mebeverine 135mg - <a href="https://coloxia.com/">colospa order online</a> buy pletal without prescription
Ioapyt
order celecoxib 100mg for sale - <a href="https://celespas.com/">order celecoxib 100mg without prescription</a> buy indomethacin 50mg generic
Tmcnlm
cambia over the counter - <a href="https://dicloltarin.com/">diclofenac 100mg price</a> order aspirin 75 mg pill
Degqse
buy rumalaya generic - <a href="https://rumaxtol.com/shallaki/">purchase shallaki generic</a> order elavil 10mg online
Zbsmjj
oral mestinon 60 mg - <a href="https://mestonsx.com/azathioprine/">order azathioprine 50mg online</a> buy imuran generic
Yspjdf
buy generic diclofenac - <a href="https://vovetosa.com/">diclofenac tablets</a> buy cheap generic nimotop
Kqwexo
brand ozobax - <a href="https://baclion.com/">order ozobax online cheap</a> buy piroxicam 20mg for sale
Csnyvc
buy cheap mobic - <a href="https://meloxiptan.com/">order mobic 15mg pill</a> toradol generic
Tldkgz
cheap periactin 4 mg - <a href="https://periheptadn.com/aszanaflex/">tizanidine online</a> purchase tizanidine generic
Diikqd
purchase artane for sale - <a href="https://voltapll.com/diclofenacgel/">order diclofenac gel for sale</a> where can i order diclofenac gel
Pvigoa
buy isotretinoin 10mg sale - <a href="https://aisotane.com/asdeltasone/">deltasone 20mg pills</a> buy deltasone pill
Lhixyv
order omnicef 300mg for sale - <a href="https://omnixcin.com/">buy omnicef tablets</a> buy generic cleocin
Aznxgq
order prednisone 20mg online cheap - <a href="https://apreplson.com/">deltasone order online</a> zovirax medication
Roucgm
buy permethrin generic - <a href="https://actizacs.com/tretinoin/">buy tretinoin without a prescription</a> order generic retin
Bmksam
how to get betamethasone without a prescription - <a href="https://betnoson.com/">betamethasone online</a> monobenzone order
Gqpowv
order metronidazole 200mg for sale - <a href="https://cenforcevs.com/">cheap cenforce 100mg</a> buy cenforce paypal
Gsqyad
order cleocin 300mg online - <a href="https://indometnp.com/">indocin 75mg generic</a> order indomethacin generic
Sbrhwk
order losartan 50mg generic - <a href="https://acephacrsa.com/">buy generic keflex</a> keflex us
Wtqlai
order bupropion sale - <a href="https://bupropsl.com/ayurslim/">ayurslim for sale</a> shuddha guggulu usa
Yebixu
modafinil usa - <a href="https://sleepagil.com/phenergan/">phenergan for sale online</a> meloset 3 mg tablet
Yvueqa
order progesterone 200mg - <a href="https://apromid.com/clomiphene/">order clomid 100mg</a> cheap clomiphene generic
Yaypco
order xeloda 500mg online cheap - <a href="https://xelocap.com/mefenamicacid/">buy mefenamic acid tablets</a> where to buy danazol without a prescription
Ceamna
norethindrone tablet - <a href="https://norethgep.com/yasmin/">order yasmin pills</a> yasmin generic
Uirono
brand cabergoline 0.5mg - <a href="https://adostilin.com/premarin/">buy premarin pills for sale</a> buy alesse medication
Dlezvc
buy estradiol 1mg pill - <a href="https://festrolp.com/anastrozole/">anastrozole 1 mg for sale</a> anastrozole oral
Hpmzpd
シルデナフィルジェネリック 通販 - <a href="https://jpedpharm.com/tadalafil/">シアリス - 50mg/100mg</a> シアリス - 50mg/100mg
Hcifha
プレドニン 副作用 - <a href="https://jpaonlinep.com/jazithromycin/">アジスロマイシン 個人輸入 おすすめ</a> ジスロマック 市販 おすすめ
Vroxso
eriacta spoon - <a href="https://eriagra.com/asildigrah/">sildigra ring</a> forzest shelf
Qffvfk
正規品プレドニン錠の正しい処方 - <a href="https://jpanfarap.com/jpaaccutane/">アキュテイン錠 20 mg 強さ</a> イソトレチノインの飲み方と効果