JQuery与CSS之图片上放置button
position:relative日常应用的时候通常是设置给position:absolute;的父层的,
父层position:relative; 子层position:absolute;的话, 就是按照父层的边界进行定位的,
不然position:absolute 会逐层向上寻找设置了position:relative的元素边界, 直到body元素..
第一种写法(连同CSS一起追加进去)
var freeOne="";
freeOne=$(".freePreviewOne").attr("data-url");
if(freeOne==null){
//没有免费视频
}else{
$("#coursePicture").append("<a class='hide-650 fade5' "+
"style='top:94px;left:150px;position:absolute;z-index:100; " +
" width: 180px;height: 60px;border: 2px solid white;" +
"display: block;color: white;text-decoration: none;" +
"letter-spacing: 1px;font-size: 16px;line-height: 20px;" +
"text-align:center;padding-top:18px;" +
"background-color: rgba(0, 0, 0, 0.44);" +
"-webkit-backface-visibility: hidden;-webkit-transition: all .3s ease-in-out;" +
"-moz-transition: all .3s ease-in-out;-ms-transition: all .3s ease-in-out;" +
"-o-transition: all .3s ease-in-out;" +
"border-radius: 10px;'"+ "href='#modal' data-toggle='modal' "+
"data-url='"+freeOne+"'> "+
"<span class='contactus' style='font-size:26px;'>试 看</span> <span class='glyphicon glyphicon-play' style='font-size:20px;top:0;bottom:2px;'></span> </a>"
);
}
页面:
<div class="es-row-wrap container-gap course-cover"> <div class="row row-5-7 course-cover-heading">
<div id="coursePicture" class="col-sm-5 picture hidden-xs" style="position: relative;">
<#if course.coverImage?has_content>
<img src="${course.coverImage}" class="img-responsive" width="436px" height="245px" />
<#else>
<img src="/resources/assets/img/default/course-large.png" class="img-responsive" />
</#if>
</div>
</div> </div>
另外一种写法:
//在课程图片上放置按钮
/* <a class="button hide-650 fade5" href="#modal" data-toggle="modal" data-url="/course/hyjgz2np/lesson/preview?lectureId=hyjgz2np0.49618492345325650.04212287697009742"> <span class="contactus"><strong>试看</strong></span> </a>
*/ //$("#coursePicture").append("<a class='btn btn-sm btn-info' href='#' style='top:120px;left:180px;position:absolute;z-index:100;'>试看</a>");
var freeOne="";
freeOne=$(".freePreviewOne").attr("data-url");
if(freeOne==null){
//没有免费视频
}else{
$("#coursePicture").append("<a class='freePreviewPicture hide-650 fade5' "+
"href='#modal' data-toggle='modal' "+
"data-url='"+freeOne+"'> "+
"<span class='contactus' style='font-size:26px;'>试 看</span> <span class='glyphicon glyphicon-play' style='font-size:20px;top:0;bottom:2px;'></span> </a>"
);
}
页面:
<style>
.freePreviewPicture{
top:94px;
left:150px;
position:absolute;
z-index:100;
width: 180px;
height: 60px;
border: 2px solid white;
display: block;
color: white;text-decoration: none;
letter-spacing: 1px;font-size: 16px;
line-height: 20px;
text-align:center;padding-top:18px;
background-color: rgba(0, 0, 0, 0.44);
-webkit-backface-visibility: hidden;
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
-ms-transition: all .3s ease-in-out;
-o-transition: all .3s ease-in-out;
border-radius: 10px;
}
</style>
<div class="es-row-wrap container-gap course-cover"> <div class="row row-5-7 course-cover-heading">
<div id="coursePicture" class="col-sm-5 picture hidden-xs" style="position: relative;">
<#if course.coverImage? has_content>
<img src="${course.coverImage}" class="img-responsive" width="436px" height="245px" />
<#else>
<img src="/resources/assets/img/default/course-large.png" class="img-responsive" />
</#if>
</div>
</div> </div>
执行效果图:
JQuery与CSS之图片上放置button的更多相关文章
- 在php中使用jquery uploadify进行多图片上传
jquery uploadify是一款Ajax风格的批量图片上传插件,在PHP中使用jquery uploadify很方便,请按照本文介绍的方法和步骤,为你的PHP程序增加jquery uploadi ...
- Uploadify & jQuery.imgAreaSelect 插件实现图片上传裁剪
在网站中需要一个图片上传裁剪的功能,借鉴这篇文章 Ajax+PHP+jQuery图片截图上传 的指点,找到了jquery.imgAreaSelect这个不错插件,能对图片进行自定义区域选择并给出坐标, ...
- jQuery:[1]实现图片上传并预览
jQuery:[1]实现图片上传并预览 原理 预览思路 1.当上传对象的input被触发并选择本地图片之后获取要上传的图片对象的URL: 2.把对象URL赋值给实现写好的img标签的src属性 Fil ...
- jquery php ajax多图片上传.上传进度,生成缩略图
本例用到其他2个php class.upload.php和 functions.php还有css和js以及img文件 下载地址为www.freejs.net/demo/91/down.zip 演示 J ...
- jQuery实现鼠标放到图片上,放大图片
<script src="../../Script/jquery-1.7.2.js" type="text/javascript"></scr ...
- html+css 在图片上添加文字
html <view class="container"> <image class="" src="{{book.image}}& ...
- jquery+html5实现单张图片上传预览
js: if (window.File && window.FileReader && window.FileList && window.Blob){ ...
- thinkphp5+layui多图片上传
准备资料 下载layui <!DOCTYPE html> <html> <head> <meta charset="utf-8"> ...
- [python][flask] Flask 图片上传与下载例子(支持漂亮的拖拽上传)
目录 1.效果预览 2.新增逻辑概览 3.tuchuang.py 逻辑介绍 3.1 图片上传 3.2 图片合法检查 3.3 图片下载 4.__init__.py 逻辑介绍 5.upload.html ...
随机推荐
- rails new app的时候设置skip-bundle
rails new app的时候设置skip-bundle rails new app --skip-bundle 这样可以越过bundle install阶段:
- MySQL 5.7.10最新版本号源码安装具体过程
,重置密码 利用mysqladmin重置密码 [root@wgq_idc_mon_1_12 mysql5710]#./bin/mysqladmin -h localhost -uroot passwo ...
- HIbernate中openSession和getCurrentSession
这两者的差别网上非常多资源,我这里就copy一下了,然后有点问题的是今天遇到的问题. openSession和getCurrentSession的根本差别在于有没有绑定当前线程,所以,用法有差 ...
- HDU 2054 A==B? 大数
Problem Description Give you two numbers A and B, if A is equal to B, you should print "YES&quo ...
- 使用IDEA 创建 MAVEN 项目
一,项目创建 1.File---New---project 选择maven 勾选Create from archtype,找到并选择org.apache.maven.archtype ...
- ROS-多机通信
前言:一定要在同一路由的局域网下进行,就是两台电脑的ip要像这样:192.168.191.4和192.168.191.8,只有最后一位不同,这样就能ping通了,否则ping不同. 一.查看ip和主机 ...
- marge into操作
动机: 想在Oracle中用一条SQL语句直接进行Insert/Update的操作. 说明: 在进行SQL语句编写时,我们经常会遇到大量的同时进行Insert/Update的语句 ,也就是说当存在记录 ...
- 实现两个jQuery的API(addClass、text)
目的 给所有的div添加一个叫“red”的class,为方便看到代码的效果,设置如下css,在设置“red”成功时,文本会变红 .red{ color:red; } 将所有的div中的textCont ...
- DirectUI界面编程(四)界面布局详解
Duilib的界面布局使用xml文件进行描述,在Duilib v1.1版本的xml布局文件中我们可以使用以下这些标签(后续版本标签有扩充): 这些标签总的来讲可以分为三类: 窗口类,该类别中只有一个W ...
- 坑人的SQL Server检测数字类型的函数ISNUMERIC
前几天,遇到一个十分棘手的问题,有同事提出在是字符类型的列中进行起止号计算,大体是这样的 新起号=上一条止号+1 新止号=新起号+数量 而在这一列的数据是这样的 库存 CN003?005007 000 ...