会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 133798个问题

1.html
<!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>webxiaode的网页</title>
    <link rel="stylesheet" href="./css/reset.css" />
    <link rel="stylesheet" href="./css/mi.css" />
    <link rel="stylesheet" href="./css/iconfont/iconfont.css" />
  </head>

  <body>
    <!-- 头部开始 -->
    <div class="header">
      <a href="#">
        <img src="./images/top.jpg" alt="" />
      </a>
    </div>
    <!-- 头部结束 -->
    <!-- 黑色导航部分开始 -->
    <!--黑色导航步骤:
            1.主容器.背景颜色
            2.内容部分居中显示,容器处理
            3.左导航,右导航
            4.动画
    -->
    <div class="black-nov">
      <div class="wrop">
        <ul class="black-nov-left">
          <li><a href="#">小米商城</a><span>|</span></li>
          <li><a href="#">MIUI</a><span>|</span></li>
          <li><a href="#">lOT</a><span>|</span></li>
          <li><a href="#">云服务</a><span>|</span></li>
          <li><a href="#">天星科技</a><span>|</span></li>
          <li><a href="#">有品</a><span>|</span></li>
          <li><a href="#">小爱开发平台</a><span>|</span></li>
          <li><a href="#">企业团购</a><span>|</span></li>
          <li><a href="#">资质证照</a><span>|</span></li>
          <li><a href="#">协议规则</a><span>|</span></li>
          <li>
            <a href="#">下载APP</a><span>|</span>
            <div class="download">
              <img src="./images/download.png" alt="" />
              <p>小米商城APP</p>
            </div>
            <div class="stri"></div>
          </li>
          <li><a href="#">智能生活</a></li>
          <li><a href="#">SelectLocation</a></li>
        </ul>
        <ul class="black-nav-right">
          <li><a href="#">登录</a><span>|</span></li>
          <li><a href="#">注册</a><span>|</span></li>
          <li><a href="#">消息通知</a><span>|</span></li>
          <li class="cart">
            <a href="#"> <span class="iconfont">&#xe607;</span>购物车(0)</a>
            <div class="cart-list">购物车中还没有商品,赶紧选购吧!</div>
          </li>
        </ul>
      </div>
    </div>
    <!-- 黑色导航部分结束 -->
  </body>
</html>

2.css样式
* {
  margin: 0;
  padding: 0;
}
/*头部样式开始*/
.header {
  width: 100%;
  height: 120px;
  overflow: hidden;
  position: relative;
}

.header img {
  height: 120px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
/*头部样式结束*/


/*黑色导航开始*/
.black-nov {
  width: 100%;
  height: 40px;
  line-height: 40px; /*行高为40px*/
  background-color: #333;
  font-size: 12px; /*设置字体大小*/
}/*导航部分*/

.wrop {
  width: 1226px;
  margin: 0 auto;
}

.black-nov-left {
  float: left;
}

.black-nov-right {
  float: right;
}

.black-nov li {
  float: left; /*字体浮动居左*/
  position: relative; /*相对定位*/
}

.black-nov a {
  color: #b0b0b0;
}

.black-nov span {
  color: #424242;
  margin: 0 3.6px;
}

.download {
  width: 124px;
  height: 0;
  background: #fff;
  box-shadow: 0 1px 5px #aaa;
  position: absolute; /*绝对定位*/
  top: 40px;
  left: 50%;
  margin-left: -62px;
  overflow: hidden; /*消除浮动*/
  transition: all 0.3s; /*过渡所有属性*/
}

.download img {
  width: 90px;
  margin: 18px auto 0;
}

.download p {
  color: #333;
  font-size: 14px;
  line-height: 14px;
}

.black-nov-left li:hover > .download {
  height: 148px;
}

.stri {
  width: 0;
  height: 0;
  border-bottom: 8px solid #fff;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  position: absolute; /*绝对定位*/
  bottom: 0;
  left: -50%; /*左右居中*/
  margin-left: 46px;
  display: none; /*默认没有*/
}

.black-nov-left li:hover > .stri {
  display: block;
} /*让它出现*/

.cart {
  width: 120px;
  高度: 40px;
  margin-left: 25px;
  background: #424242;
  position: relative;
}

.cart span{
  color: #b0b0b0;
}

.cart:hover {
  background: #fff;
}

.cart a:hover{
  color: #ff6700;
}

.cart-list {
  width: 316px;
  height: 0;
  background: #fff;
  box-shadow: 0 2px 10px rgb(0, 0, 0,0.15);
  position: absolute; /*绝对定位*/
  top: 40px;
  right: 0;
  颜色 : #424242;
  overflow: hidden; /*消除浮动*/
  transition: all 0.3s; /*过渡所有属性*/
  行高:100px;
}

.cart:hover>.cart-list{
  高度: 100px;
}
/*黑色导航结束*/

问题:左边导航和右边导航连接在一起了,怎么解决啊

1648288891(1).png

WEB前端全系列/第一阶段:HTML5+CSS3模块/商城官网项目 5446楼

/* 黑色导航开始 */
.black-nav{
 width: 100%;
 height: 40px;
 background-color: #333;  
 line-height: 40px;
 
}
.wrap{
    width: 1226px;
    margin: 0 auto;
    /* position: relative; */
}
.left-nav{
    float: left;
}
.right-nav{
    float: right;
}
.black-nav li{
    float: left;
    position: relative;
}
.black-nav a{
    color: #b0b0b0;
    font-size: 12px;
}
.black-nav span{
    color: #424242;
    margin: 0 3.6px;
}
.black-nav a:hover{
    color: #fff;
}
.download{
    width: 124px;
    height: 0;
    background-color: #fff;
    position:absolute;
    top: 40px;
    left: -50%;
    display: none;
    box-shadow: 0 1px 5px #333 ;
    transition: all 0.5s;
    /* margin-left: -62px; */
}
.download img{
    width: 90px;
    margin: 18px auto 0;
}
.left-nav li:hover>.download{
    height: 148px;
    display: block;
   
}
.download p{
    color: #424242;
    font-size: 14px;
    line-height: 14px;
}
.triangle{
    width: 0;
    height: 0;
    border-bottom: 8px solid #fff;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    position: absolute;
    bottom: 0px;
    right: 50%;
    margin-left: -8px;
    display: none;
}
.left-nav li:hover>.triangle{
    display: block;
}
.cart{
    width: 120px;
    height: 40px;
    background: #424242;
    margin-left: 20px;
}
.cart span{
    color: #b0b0b0;
}
.cart:hover{
    background: #fff;
}
.cart:hover>a{
    color: #ff6700;
}
.cart i{
    font-style: normal;
    padding-left: 5px;
    position: relative;
}
.cart-1{
    width: 320px;
    height: 0px;
    position: absolute;
    top: 40px;
    right: 0;
    box-shadow: 0 1px 5px rgba(0,0,0,0.2);
    transition: all 0.5s;
    line-height: 100px;
}
.cart:hover>.cart-1{
    height: 100px;
}

/* 黑色导航结束 */

/* 白色导航开始 */
.withe-nav{
    width: 100%;
    height: 100px;
    background: #fff;
    position: relative;
    clear: both;
    line-height: 100px;
}
.logo{
    float: left;
}
.white-left-nav{
    width: 850px;
    float: left;
}
.white-right-nav{
    width: 296px;
    float: right;
}
.logo{
    width: 56px;
    height: 56px;
    margin-top: 22.5px;
}
.logo img{
    width: 56px;
    height: 56px;
    left: 0;
}
.white-left-nav li{
    padding: 5px 0 0 30px;
    float: left;
    box-sizing: border-box;
}
.white-left-nav li a{
    color: #333;
    font-size: 16px;
}
.white-left-nav>ul>li>a:hover{
    color: #ff6700;
}
.white-left-nav ul{
    margin-left: 113px;
}
.white-right-nav input{
    width: 244px;
    height: 50px;
    line-height: 50px;
    padding: 0 10px;
    font-size: 14px;
    box-sizing: border-box;
    border: 1px solid #e0e0e0;
    margin-top: 25px;
}
.white-right-nav button{
    width: 52px;
    height: 50px;
    font-size: 24px;
    line-height: 50px;
    background-color: #fff;
    color: #616161;
    box-sizing: border-box;
    border: 1px solid #e0e0e0;
    border-left: 0;
    margin-top: 25px;
    float: right;
}
.white-right-nav button:hover{
    background-color: #ff6700;
    color: #fff;
}
.item{
    width: 100%;
    height: 229px;
    position: absolute;
    top: 100px;
    left: 0;
}



/* 白色导航结束 */


WEB前端全系列/第一阶段:HTML5+CSS3模块/商城官网项目 5448楼
Python 全系列/第六阶段:数据库与AI协同技术实战/python操作mysql(旧) 5450楼

问题一:

老师,我想在点击新增一行这个按钮时新增的一行可以自定义书名,作者,数量,但是我发现我写的代码只能自定义书名和作者,而且数量随着书名和作者的值变化而变化,如果先在书名里面写张三那么数量也变为张三,然后在作者里面写李四,这时候数量又变成了李四,老师这个我该怎么解决


问题二:

我在书名,作者和数量的input里面都调用了失去焦点的方法,为什么只有数量可以成功调用,写完之后鼠标点击其他地方文本框边框消失,而作者和书名却不行


问题动图如下:


GIF.gif



源码如下:


html:

<html>
	<head>
		<title>jQuery操作表格</title>
		<meta charset="UTF-8"/>
		<!--声明css代码域-->
		<style type="text/css">
			tr{
				height: 40px;
			}
		</style>
	 
	 	<script src="js/jquery-1.9.1.js" type="text/javascript" charset="utf-8"></script>
		
		<script src="js/gwc.js"	type="text/javascript" charset="UTF-8"></script>
		
	</head>
	<body>
		<h3>jQuery操作表格</h3>
		<hr />
		<input type="button" id="fx" value="反选" />
		<input type="button" id="addRow" value="新增一行" />
		<input type="button" id="delRow" value="删除行" />
		<input type="button" id="copyRow" value="复制行" />
		<table border="1px" cellpadding="10px" cellspacing="0" id="ta">
			<tr>
				<td width="50px"><input type="checkbox" name="chks" id="chks" value="1" /></td>
				<td width="200px">书名</td>
				<td width="200px">作者</td>
				<td width="200px">数量</td>
				<td width="200px">操作</td>
			</tr>
			<tr id="">
				<td><input type="checkbox" name="chk" id="" value="2"/></td>
				<td>《Java编程之道》</td>
				<td>wollo</td>
				<td>10</td>
				<td>
					<input type="button" name="aa" id="" value="修改数量"  onclick="change(this)"/>
					<input type="button" name="" id="" value="删除" onclick="del(this)"/>
				</td>
			</tr>
			<tr>
				<td><input type="checkbox" name="chk" id="" value="3" /></td>
				<td>《Python和我的故事》</td>
				<td>赵老师</td>
				<td>10</td>
				<td>
					<input type="button" name="" id="" value="修改数量" onclick="change(this)"/>
					<input type="button" name="" id="" value="删除" onclick="del(this)"/>
				</td>
			</tr>
			<tr>
				<td><input type="checkbox" name="chk" id="" value="4" /></td>
				<td>《web开发详解》</td>
				<td>张老师</td>
				<td>30</td>
				<td>
					<input type="button" name="" id="" value="修改数量" onclick="change(this)"/>
					<input type="button" name="" id="" value="删除" onclick="del(this)"/>
				</td>
			</tr>			
		</table>
	</body>
</html>


JS:

$(function(){
	
	//确定全选和全部不选操作
	
	$("#chks").click(function(){
		
		var flag = $(this).prop("checked");//返回布尔类型
		
			$("input[name=chk]").prop("checked",flag);//让所有内容都选中

	})
	
	//判断是否全选的操作
	$("input[name=chk]").click(function(){
		
		var flag = true;
		
		var chk = $("input[name=chk]");
		
		//each:遍历		每次遍历执行funaction 里面的内容
		chk.each(function(){
			
			if(!$(this).prop("checked")){
				
				flag = false;
				
				return;
			}
			
		})
		
		$("#chks").prop("checked",flag);
		
	})
	
	//反选的操作
	$("#fx").click(function(){
		
		//拿到所有的多选框
		var chx = $("input[name=chk]");
		
		//遍历
		chx.each(function(){
			
			//获得每个多选框的初始状态
			var flag = $(this).prop("checked");
			
			//现有状态与原始状态进行取反
			$(this).prop("checked",!flag);
		})
	})
	
	//新增加一行的操作
	$("#addRow").click(function(){
		
		//获得tab对象
		var tab = $("#ta");
		
		tab.append('<tr id="">'+
				'<td><input type="checkbox" name="chk" id="" value="2"/></td>'+
				'<td><input type="text"	onblur="bul(this)"/></td>'+
				'<td><input type="text"	onblur="bul(this)"/></td>'+
				'<td><input type="text"	onblur="bul(this)"/></td>'+
				'<td>'+
					'<input type="button" name="aa" id="" value="修改数量"  onclick="change(this)"/>&nbsp'+
					'<input type="button" name="" id="" value="删除" onclick="del(this)"/>'+
				'</td>'+
			'</tr>');
		
	})
	
	//删除的操作
	$("#delRow").click(function(){
		
		//获得被选中的name=chk的单选框
		var del = $("input[name=chk]:checked");
		
		if(del.length==0){//如果一行没选
			alert("至少选择一行!");
		}else{
			
			//执行删除整行的操作	单选框的父节点是	td	,	td	的父节点是	tr
			del.parent().parent().remove();
		}
		
	})
	
	//复制行		选中几个复制几个
	$("#copyRow").click(function(){
		
		//获得被选中的name=chk的多选框
		var copy = $("input[name=chk]:checked");
		
		if(copy.length==0){//如果一行没选
			alert("至少选择一行!");
		}else{
			//执行copy的操作
			
			//复制
			var tr = copy.parent().parent().clone();//克隆整行
			//黏贴
			$("#ta").append(tr);
			
		}
	})
	
})

//修改数量的操作

function change(th){//这里的this是JS类型的,得转换成JQ对象
	
	//$(th):转换成JQ对象		获得	tr	结点
	var par = $(th).parent().parent();
	
	//将写死的数量变成可以定义的文本框
	par.children().eq(3).html("<input	type='text' size='3px' onblur='bul(this)'/>");
}

function bul(th){
	
	var par = $(th).parent().parent();
	
	par.children().eq(3).html(th.value);//或者转成JQ对象再调用val来获得值
}

function del(th){
	
	var par = $(th).parent().parent();
	
	par.remove();
	
}


JAVA 全系列/第五阶段:网页编程和设计/Jquery(旧) 5453楼
JAVA 全系列/第四阶段:数据库与AI协同技术实战/MySQL数据库 5455楼
Python 全系列/第七阶段:网页编程基础/jquery 5458楼

分享,解决centos6.8上安装Twisted-19.7.0报错"ModuleNotFoundError: No module named '_ctypes'"的方法考网上解决办法:

  1. 安装外部函数库(libffi)

    yum install libffi-devel -y
  2. 重新安装python

  3. 用pip3 Install 安装需要的包

    再次报错:distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('incremental>=16.10.1')

参考网上解决办法:

yum install -y epel-release
yum install -y python-pip
pip3 install incremental -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
cd Twisted-19.7.0
python3 setup.py install

再次报错:error: Could not find suitable distribution for Requirement.parse('attrs>=17.4.0')

解决办法

pip3 install attrs -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
cd Twisted-19.7.0
python3 setup.py install

再次报错:error: Could not find suitable distribution for Requirement.parse('PyHamcrest>=1.9.0')

pip3 install PyHamcrest -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
cd Twisted-19.7.0
python3 setup.py install

再次报错:error: Could not find suitable distribution for Requirement.parse('hyperlink>=17.1.1')

pip3 install hyperlink -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
cd Twisted-19.7.0
python3 setup.py install

再次报错:error: Could not find suitable distribution for Requirement.parse('Automat>=0.3.0')

pip3 install Automat -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
pip3 install constantly -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
pip3 install zope.interface -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
cd Twisted-19.7.0
python3 setup.py install

执行上述操作后:linux界面提示Finished processing dependencies for Twisted==19.7.0



Python 全系列/第十六阶段:Python 爬虫开发/分布式爬虫 5459楼
JAVA 全系列/第一阶段:AI驱动的JAVA编程/JAVA入门和背景知识 5460楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637