float:left;overflow: hidden;white-space:nowrap;text-overflow:ellipsis;

本文深入探讨了网页布局中四个关键CSS属性:float、overflow、white-space和text-overflow。通过详细解释每个属性的作用、用法及其相互关系,帮助开发者更有效地控制网页元素的布局和文本显示方式。
.li {
width:20%;
float:left;   // 文本或图像会移至父元素中的左侧。 
overflow: hidden; //不显示超过对象尺寸的内容
white-space:nowrap;   // 默认处理方式。文本自动处理换行。假如抵达容器边界内容会转到下一行
text-overflow:ellipsis;   //当对象内文本溢出时显示省略标记(...)
}



float 
该属性的值指出了对象是否及如何浮动。

取值:
none   : 默认值。对象不飘浮 
left   : 文本流向对象的右边 
right   : 文本流向对象的左边 

overflow
检索或设置当对象的内容超过其指定高度及宽度时如何管理内容。

取值:
visible   : 默认值。不剪切内容也不添加滚动条。假如显式声明此默认值,对象将以包含对象的 window 或 frame 的尺寸裁切。并且 clip 属性设置将失效 
auto   : 在必需时对象内容才会被裁切或显示滚动条 
hidden   : 不显示超过对象尺寸的内容 
scroll   : 总是显示滚动条 

white-space
设置或检索对象内空格的处理方式。

取值:
normal   : 默认值。默认处理方式。文本自动处理换行。假如抵达容器边界内容会转到下一行 
pre   : 换行和其他空白字符都将受到保护。这个值需要IE6+或者 !DOCTYPE 声明为 standards-compliant mode 支持。如果 !DOCTYPE 声明没有指定为 standards-compliant mode ,此属性可以使用,但是不会发生作用。结果等同于 normal 。参阅 pre 对象 
nowrap   : 强制在同一行内显示所有文本,直到文本结束或者遭遇 br 对象。参阅 noWrap 属性 

text-overflow
设置或检索是否使用一个省略标记(...)标示对象内文本的溢出。

取值:
clip   : 默认值。不显示省略标记(...),而是简单的裁切 
ellipsis   : 当对象内文本溢出时显示省略标记(...) 

注意:text-overflow属性仅是注解,当文本溢出时是否显示省略标记。并不具备其它的样式属性定义。我们想要实现溢出时产生省略号的效果。还必须定义:强制文本在一行内显示(white-space:nowrap)及溢出内容为隐藏(overflow:hidden)。只有这样才能实现溢出文本显示省略号的效果。

<view class="content-item-info"> <view class="content-item-text-name"> <view class="content-item-text-names">{{item.name}}</view> <view class="content-item-text-id">({{item.no}})</view> </view> <text class="content-item-text-tag" wx:for="{{item.positions}}" wx:for-item='position' wx:key="index" wx:if="{{index === 0}}">{{position.name}}<text wx:if="{{item.positions.length > 1}}">...</text></text> <view wx:if="{{item.verified == 2 || item.verified == '2'}}" class="status-tag status-verified">{{verifiedDict[item.verified]}}</view> <view wx:elif="{{item.verified == 7 || item.verified == '7'}}" class="status-tag status-graduated">{{verifiedDict[item.verified]}}</view> <view wx:else class="status-tag status-other">{{verifiedDict[item.verified]}}</view> </view>.content-item { background: #fff; border-top-style: solid; border-bottom-style: solid; border-width: 8rpx; border-color: #f2f2f2; height: 150rpx; display: flex; align-items: center; /* justify-content: space-between; */ } .content-item-text { width: calc(100% - 80rpx); padding-left: 20rpx; padding-right: 20rpx; } .content-item-info { display: flex; align-items: center; margin-bottom: 10rpx; } .content-item-img { height: 80rpx; width: 80rpx; margin-left: 30rpx; border-radius: 50%; /* 使图片变为圆形 */ overflow: hidden; /* 确保图片不会超出容器 */ } .content-item-text-name { /* display: block; */ font-size: 30rpx; font-weight: bold; color: rgba(0, 0, 0, 0.65); } content-item-text-names { float: left; } content-item-text-id { float: left; } .content-item-text-tag { display: block; font-size: 24rpx; color: #3391f5; padding: 4rpx 16rpx; margin-left: 14rpx; background: #c6e2ff; } .status-tag { margin-left: auto; font-size: 24rpx; padding: 4rpx 15rpx; border-radius: 20rpx; color: #4ea5ff; } .status-verified { background-color: #ecf5ff; } .status-graduated { background-color: #fdf6ec; color:#ecb66f; } .status-other { /* background-color: #c3cbd3; */ background-color: #f4f4f5; color:#909399; } .content-item-text-class { font-size: 26rpx; color: rgba(0, 0, 0, 0.45); }我现在改成这样了左边姓名学号列的分成两个盒子放在一个盒子里去了,我现在想要名字短的话就让名字和学号一行显示,像我图片第一个用户就是名字长了,就想现在这样姓名和学号换行显示
最新发布
12-11
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style type="text/css"> p.title{ font-size: 18px; line-height: 29px; } p.title em{ color: #F73131; text-decoration: underline; } p.title span{ color: #2440B3; text-decoration: underline; } div.container { display: flex; align-items: flex-end; width: 605px; } div.left{ float: left; margin-right: 14px; } div.left img{ width: 142px; height: 93px; display: block; } div.right{ width: 449px; } div.right span.up{ font-size: 13px; color: #333333; line-height: 21px; height: 63px; overflow: hidden; position: relative; display: block; margin-bottom: 11px; } div.right span.color{ color: #F73131; } div.right a{ font-size: 13px; color:#9195A3; width: 170px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; display: block; text-decoration: none; } .ellipsis { position: absolute; right: 0; bottom: 0; background: white; padding-left: 3px; } </style> </head> <body> <p class="title">CSS <span>教程</span></p > <div class="left"> < img src="imgs/w3.jpg"> </div> <div class="right"> <span class="up">本<span class="color">CSS </span>教程包含数百个 CSS 实例。通过使用我们的在线编辑器(W3School TIY),您可以编辑 CSS,然后单击运行按钮来查看结果。CSS 实例body{background-color:lightblue;}h1{color:white;text-align:center;}p{font-family:verdana;font-size:20px}</span> <a href=" ">www.w3school.com.cn/css/index.asp</a > </div> </body> </html>
10-10
<?php date_default_timezone_set('Asia/Shanghai'); // 强制使用北京时间 require_once './include/conn.php'; // 获取当前用户历史消息并按时间排序 $h_user = getUserIP(); $rs = $db->get_one("select count(*) as tj from `h_kefu` where h_user = '{$h_user}' and h_who = 2 and h_isread = 0"); if($rs['tj'] > 0){ $query = "select * from `h_kefu` where h_user = '{$h_user}' and h_isread = 1 order by h_addTime asc,id asc"; }else{ $query = "select * from `h_kefu` where h_user = '{$h_user}' order by h_addTime asc,id asc"; } $result = $db->query($query); $messages = []; while($rs_list = $db->fetch_array($result)){ $messages[] = $rs_list; } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0,user-scalable=no"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>安全访问</title> <link rel="stylesheet" href="/css/style7881.css"> <link rel="stylesheet" href="/iconfont/iconfont.css"> <link rel="stylesheet" href="/css/78812.6.0.css"> <link rel="stylesheet" href="https://res.qiyukf.net/sdk/tr/t_trade_mobile_m0_6dd2352f062861470694467bda09b417.css"> <link rel="icon" href="" type="image/x-icon"> <style> /* 原有主题样式保持不变 */ /** * =========================== * Visitor-end - Skin variable theme color - Common layout * =========================== */ /* trade */ .g-mask{background-color: #337eff;} .g-slide .slide_hd{background-color: #337eff;} .body_hd{background-color: #337eff;} .head-minsize{background-color: #337eff;} .m-msglist .msg_right .bot .text+.arrow:before{border-left-color:#337eff;} /* trade end */ .g-hd{background-color: #337eff;} .g-td.now_robot .u-btn, .g-td.now_robot .u-btn:link, .g-td.now_robot .u-btn:hover, .g-td.now_robot .u-btn:active{background-color: #337eff; -moz-opacity:0.6;-khtml-opacity: 0.6;opacity: 0.6;} .g-td.now_robot .form_cnt_send .u-btn{background-color: #337eff;} .g-td.now_robot .form_cnt_send .u-btn:link{background-color:#337eff; -moz-opacity:0.6;-khtml-opacity: 0.6;opacity: 0.6;} .g-td.now_robot .form_cnt_send .u-btn:hover{background-color:#337eff; -moz-opacity:0.8;-khtml-opacity: 0.8;opacity: 0.8;} .g-td.now_robot .form_cnt_send .u-btn:active{background-color:#337eff; -moz-opacity:0.6;-khtml-opacity: 0.6;opacity: 0.6;} /** * ================== * module * ================== */ .m-msglist .msg_bubble .textcolor {color: #337eff !important} .m-msglist .msg .bordercolor{border: 1px solid #337eff} .m-msglist .msg_right .text, .m-msglist .msg_right .qa, .m-msglist .msg_right .qa-list, .m-msglist .msg_right .action, .m-msglist .msg_right .rich, .m-msglist .msg_right .mobile-file, .m-msglist .msg_right .question{background-color: #337eff;border-color: #337eff;} .m-msglist .msg_right .un-read{color: #337eff} .m-msglist .msg_right .text .arrow, .m-msglist .msg_right .text .arrow:before, .m-msglist .msg_right .image .arrow, .m-msglist .msg_right .image .arrow:before, .m-msglist .msg_right .qa .arrow, .m-msglist .msg_right .qa .arrow:before, .m-msglist .msg_right .qa-list .arrow, .m-msglist .msg_right .qa-list .arrow:before, .m-msglist .msg_right .action .arrow, .m-msglist .msg_right .action .arrow:before, .m-msglist .msg_right .rich .arrow, .m-msglist .msg_right .rich .arrow:before, .m-msglist .msg_right .question .arrow, .m-msglist .msg_right .question .arrow:before, .m-msglist .msg_right .audio .audio-wrap .arrow, .m-msglist .msg_right .audio .audio-wrap .arrow:before, .m-msglist .msg_right .mobile-file .arrow:before, .m-msglist .msg_right .mobile-file .arrow, .m-msglist .msg_right .crm-thirdorder .arrow{border-left-color:#337eff;} .m-msglist .msg_right .crm-thirdorder .text+.arrow:before{border-left-color:#337eff;} .m-msglist .msg_right .crm-thirdorder-bd{ border-color: #337eff;} .m-msglist .msg_left .u-icon-avater{background-color: #fff;} .m-msglist .msg_right .u-icon-avater{background-color: #337eff;} .m-msglist .msg_right .audio .audio-wrap, /* Bot/FAQ fusion template - Message - Web version */ .m-msglist .msg_right .crm-thirdorder .qiyu_template_mixReply .crm-thirdorder-bd{ border-color: #337eff; background-color: #337eff; color:#fff; } .m-msglist .msg_right .qiyu_template_mixReply+.arrow{ border-left-color: transparent; } .m-msglist .msg_right .qiyu_template_mixReply+.arrow:before{ border-left-color: #337eff; } /* Bot/FAQ fusion template - Message - Web version - Trade adaptation */ .m-msglist .msg_right .qiyu_template_mixReply .bot-bd{ border-color: #337eff; background-color: #337eff; color:#fff; } /* Bot/FAQ fusion template - Message - Mobile version */ .m-msglist .msg_right .crm-thirdorder .qiyu_template_mixReply .crm-thirdorder-bd+.arrow{ border-left-color: transparent; } .m-msglist .msg_right .crm-thirdorder .qiyu_template_mixReply .crm-thirdorder-bd+.arrow:before{ border-left-color: #337eff; } .m-modal-confirmphoto .ok{background-color: #337eff;} .m-modal-confirmphoto .ok:hover{background-color:#337eff; -moz-opacity:0.8;-khtml-opacity: 0.8;opacity: 0.8;} .m-modal-confirmphoto .ok:active{background-color:#337eff; -moz-opacity:0.6;-khtml-opacity: 0.6;opacity: 0.6;} .m-form-evaluate .form_item.itm-tag-list .tag-item.active{color: #337eff; border-color: #337eff} .m-form-evaluate .m-solve .z-sel{color: #337eff; border-color: #337eff} .m-modal-filetrans .ok{background-color: #337eff;} .m-modal-filetrans .ok:hover{background-color:#337eff; -moz-opacity:0.8;-khtml-opacity: 0.8;opacity: 0.8;} .m-modal-filetrans .ok:active{background-color:#337eff; -moz-opacity:0.6;-khtml-opacity: 0.6;opacity: 0.6;} .m-comment .comment_btn{background-color: #337eff;} .m-comment .comment_btn:hover{background-color:#337eff; -moz-opacity:0.8;-khtml-opacity: 0.8;opacity: 0.8;} .m-comment .comment_btn:active{background-color:#337eff; -moz-opacity:0.6;-khtml-opacity: 0.6;opacity: 0.6;} .m-botentry li {border-color : #337eff} .m-botentry li.highLight:after {background-color : #337eff} .radio_button .button-multiple .enter-content-item .reply-button-li.highlight{color:#337eff;border-color:#337eff} .radio_button .button-multiple-enter.highlight{background:#337eff} .bot .date-picker {background-color : #337eff} .rmc-picker-popup-header .rmc-picker-popup-item { color: #337eff} /* Theme color of pagination button */ .g-chat-body .chat_show_bot .icon-triangle-left, .g-chat-body .chat_show_bot .icon-triangle-right, .radio_button .icon-triangle-left, .radio_button .icon-triangle-right { background-color:#337eff; } /* Theme color of title of robot's frequently asked question card style */ .m-msglist .msg .qa-list >.p.p_card >.qa_label {color: #337eff} .m-msglist .msg .qa-list >.p.p_card >.qa_label-contain >.qa_label {color: #337eff} .m-msglist .msg .qa-list >.p.p_card >.qa_label-contain >.qa_select > .tabs > .z-current {color: #337eff} /* Theme color of robot's frequently used shortcut entry */ .m-msglist .msg .quick-entry-icon {color: #337eff} /* Theme color of robot's evaluation */ .m-msglist .msg_bubble .eval-robot-answer.z-sel {color: #337eff} .m-msglist .msg .qa .qa_eval_tag.sel {color: #337eff; border: 1px solid #337eff} .m-msglist .msg .qa-list .qa_eval_tag.sel {color: #337eff; border: 1px solid #337eff} .z-disabled button, .z-disabled button:link, .z-disabled button:hover, .z-disabled button:active{background-color: #337eff; -moz-opacity:0.6;-khtml-opacity: 0.6;opacity: 0.6;} .u-btn, .u-btn-loadding, .u-btn:link, .u-btn:hover{background-color:#337eff;} .u-btn:active, .u-btn.z-disabled, .u-btn.z-disabled:hover, .u-btn.z-disabled:active, .u-btn.z-disabled:link{background-color: #337eff; -moz-opacity:0.6;-khtml-opacity: 0.6;opacity: 0.6;} .u-btn-disabled, .u-btn-disabled:link, .u-btn-disabled:hover, .u-btn-disabled:active{background-color: #337eff;-moz-opacity:0.6;-khtml-opacity: 0.6;opacity: 0.6;} .u-border-btn, .u-border-btn:hover{background-color: #fff;border: 1px solid #337eff; color: #337eff !important} .service-action, .service-action:link, .service-action:hover{background-color:#337eff !important; color: #fff !important; border: 0 !important} .m-pre-evaluation .pre-evaluation-box .evaluation{background-color: #337eff}, </style> <style type="text/css"> ::-webkit-scrollbar { width: 4px; height: 4px; } ::-webkit-scrollbar-button { display: none; } ::-webkit-scrollbar-thumb { border-radius: 3px; background: #dddfe0; } ::-webkit-scrollbar-track { width: 7px; height: 7px; } ::-webkit-scrollbar-track-piece { background: transparent; } .vc-switch { bottom: 170px !important; } </style> <style>.rmc-picker, .rmc-multi-picker { height: 238px; /*34*7*/ } .rmc-multi-picker { display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-align: center; -ms-flex-align: center; align-items: center; } .rmc-picker-item { font-size: 16px; height: 34px; line-height: 34px; padding: 0 10px; white-space: nowrap; position: relative; overflow: hidden; text-overflow: ellipsis; color: #9b9b9b; width: 100%; -webkit-box-sizing: border-box; box-sizing: border-box; } .rmc-picker { display: block; position: relative; overflow: hidden; width: 100%; -webkit-box-flex: 1; -ms-flex: 1; flex: 1; text-align: center; } .rmc-picker-mask { position: absolute; left: 0; top: 0; height: 100%; margin: 0 auto; width: 100%; z-index: 3; background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(255, 255, 255, 0.95)), to(rgba(255, 255, 255, 0.6))), -webkit-gradient(linear, left bottom, left top, from(rgba(255, 255, 255, 0.95)), to(rgba(255, 255, 255, 0.6))); background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.6)), linear-gradient(to top, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.6)); background-position: top, bottom; background-size: 100% 204px; background-repeat: no-repeat; } .rmc-picker-content { position: absolute; left: 0; top: 0; width: 100%; z-index: 1; } .rmc-picker-indicator { -webkit-box-sizing: border-box; box-sizing: border-box; width: 100%; height: 34px; position: absolute; left: 0; top: 102px; z-index: 3; border-top: 1PX solid #ddd; border-bottom: 1PX solid #ddd; } </style> <style>.rmc-date-picker { display: -ms-flexbox; display: -webkit-box; display: flex; -ms-flex-align: center; -webkit-box-align: center; align-items: center; padding: 10px 0; } .rmc-date-picker-item { -ms-flex: 1; -webkit-box-flex: 1; flex: 1; text-align: center; } </style> <style>.rmc-picker-popup { left: 0; bottom: 0; position: fixed; width: 100%; background-color: #fff; } .rmc-picker-popup-close { display: none; } .rmc-picker-popup-wrap { position: fixed; overflow: auto; top: 0; right: 0; bottom: 0; left: 0; z-index: 1050; overflow-scrolling: touch; outline: 0; } .rmc-picker-popup-mask { position: fixed; top: 0; right: 0; left: 0; bottom: 0; background-color: #373737; background-color: rgba(55, 55, 55, 0.6); height: 100%; filter: alpha(opacity=50); z-index: 1050; } .rmc-picker-popup-mask-hidden { display: none; } .rmc-picker-popup-header { background-image: -webkit-gradient(linear, left top, left bottom, from(#e7e7e7), color-stop(#e7e7e7), color-stop(transparent), to(transparent)); background-image: linear-gradient(to bottom, #e7e7e7, #e7e7e7, transparent, transparent); background-position: bottom; background-size: 100% 1px; background-repeat: no-repeat; position: relative; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-orient: horizontal; -webkit-box-direction: normal; -ms-flex-direction: row; flex-direction: row; } .rmc-picker-popup-header-left, .rmc-picker-popup-header-right { padding-left: 15px; padding-right: 15px; } .rmc-picker-popup-item { color: #0ae; font-size: 18px; height: 44px; line-height: 44px; cursor: pointer; -webkit-box-sizing: border-box; box-sizing: border-box; text-align: center; -webkit-tap-highlight-color: transparent; } .rmc-picker-popup-item-active { background-color: #ddd; } .rmc-picker-popup-title { -webkit-box-flex: 1; -ms-flex: 1; flex: 1; color: #666; cursor: default; } .rmc-picker-popup-fade-enter, .rmc-picker-popup-fade-appear { opacity: 0; -webkit-animation-duration: 0.3s; animation-duration: 0.3s; -webkit-animation-fill-mode: both; animation-fill-mode: both; -webkit-animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2); animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2); -webkit-animation-play-state: paused; animation-play-state: paused; } .rmc-picker-popup-fade-leave { -webkit-animation-duration: 0.3s; animation-duration: 0.3s; -webkit-animation-fill-mode: both; animation-fill-mode: both; -webkit-animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2); animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2); -webkit-animation-play-state: paused; animation-play-state: paused; } .rmc-picker-popup-fade-enter.rmc-picker-popup-fade-enter-active, .rmc-picker-popup-fade-appear.rmc-picker-popup-fade-appear-active { -webkit-animation-name: rmcPopupPickerFadeIn; animation-name: rmcPopupPickerFadeIn; -webkit-animation-play-state: running; animation-play-state: running; } .rmc-picker-popup-fade-leave.rmc-picker-popup-fade-leave-active { -webkit-animation-name: rmcPopupPickerFadeOut; animation-name: rmcPopupPickerFadeOut; -webkit-animation-play-state: running; animation-play-state: running; } @-webkit-keyframes rmcPopupPickerFadeIn { 0% { opacity: 0; } 100% { opacity: 1; } } @keyframes rmcPopupPickerFadeIn { 0% { opacity: 0; } 100% { opacity: 1; } } @-webkit-keyframes rmcPopupPickerFadeOut { 0% { opacity: 1; } 100% { opacity: 0; } } @keyframes rmcPopupPickerFadeOut { 0% { opacity: 1; } 100% { opacity: 0; } } .rmc-picker-popup-slide-fade-enter, .rmc-picker-popup-slide-fade-appear { -webkit-transform: translate(0, 100%); -ms-transform: translate(0, 100%); transform: translate(0, 100%); } .rmc-picker-popup-slide-fade-enter, .rmc-picker-popup-slide-fade-appear, .rmc-picker-popup-slide-fade-leave { -webkit-animation-duration: 0.3s; animation-duration: 0.3s; -webkit-animation-fill-mode: both; animation-fill-mode: both; -webkit-animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2); animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2); -webkit-animation-play-state: paused; animation-play-state: paused; } .rmc-picker-popup-slide-fade-enter.rmc-picker-popup-slide-fade-enter-active, .rmc-picker-popup-slide-fade-appear.rmc-picker-popup-slide-fade-appear-active { -webkit-animation-name: rmcPopupPickerSlideFadeIn; animation-name: rmcPopupPickerSlideFadeIn; -webkit-animation-play-state: running; animation-play-state: running; } .rmc-picker-popup-slide-fade-leave.rmc-picker-popup-slide-fade-leave-active { -webkit-animation-name: rmcPopupPickerSlideFadeOut; animation-name: rmcPopupPickerSlideFadeOut; -webkit-animation-play-state: running; animation-play-state: running; } @-webkit-keyframes rmcPopupPickerSlideFadeIn { 0% { -webkit-transform: translate(0, 100%); transform: translate(0, 100%); } 100% { -webkit-transform: translate(0, 0); transform: translate(0, 0); } } @keyframes rmcPopupPickerSlideFadeIn { 0% { -webkit-transform: translate(0, 100%); transform: translate(0, 100%); } 100% { -webkit-transform: translate(0, 0); transform: translate(0, 0); } } @-webkit-keyframes rmcPopupPickerSlideFadeOut { 0% { -webkit-transform: translate(0, 0); transform: translate(0, 0); } 100% { -webkit-transform: translate(0, 100%); transform: translate(0, 100%); } } @keyframes rmcPopupPickerSlideFadeOut { 0% { -webkit-transform: translate(0, 0); transform: translate(0, 0); } 100% { -webkit-transform: translate(0, 100%); transform: translate(0, 100%); } } </style> <style>.fishd-spin { font-family: "Monospaced Number", "Chinese Quote", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 1.5; color: #333; -webkit-box-sizing: border-box; box-sizing: border-box; margin: 0; padding: 0; list-style: none; color: #337eff; opacity: 0; position: absolute; -webkit-transition: -webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86); transition: -webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86); transition: transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86); transition: transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86), -webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86); display: none; } .fishd-spin-container { height: 100%; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center; } .fishd-spin-text-loading { color: #999; text-align: center; } .fishd-spin-text-loading-dot i { -webkit-animation: fishdDot 2s steps(1, end) infinite; animation: fishdDot 2s steps(1, end) infinite; } .fishd-spin-spinning { height: 100%; opacity: 1; position: static; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center; } .fishd-spin-nested-loading { position: relative; } .fishd-spin-nested-loading > div > .fishd-spin { position: absolute; height: 100%; max-height: 320px; width: 100%; z-index: 4; } .fishd-spin-nested-loading > div > .fishd-spin-sm .fishd-spin-text { font-size: 12px; } .fishd-spin-nested-loading > div > .fishd-spin-lg .fishd-spin-text { font-size: 18px; } .fishd-spin-nested { position: relative; zoom: 1; } .fishd-spin-nested:before, .fishd-spin-nested:after { content: ""; display: table; } .fishd-spin-nested:after { clear: both; } .fishd-spin-nested:before, .fishd-spin-nested:after { content: ""; display: table; } .fishd-spin-nested:after { clear: both; } .fishd-spin-blur { pointer-events: none; user-select: none; overflow: hidden; opacity: 0.7; -webkit-filter: blur(0.5px); filter: blur(0.5px); /* autoprefixer: off */ filter: progid\:DXImageTransform\.Microsoft\.Blur(PixelRadius\=1, MakeShadow\=false); } .fishd-spin-blur:after { content: ''; position: absolute; left: 0; right: 0; top: 0; bottom: 0; background: #fff; opacity: 0.3; -webkit-transition: all 0.3s; transition: all 0.3s; z-index: 10; } .fishd-spin-tip { color: #666; } .fishd-spin-dot { position: relative; display: inline-block; font-size: 20px; width: 20px; height: 20px; } .fishd-spin-dot i { width: 9px; height: 9px; border-radius: 100%; background-color: #337eff; -webkit-transform: scale(0.75); -ms-transform: scale(0.75); transform: scale(0.75); display: block; position: absolute; opacity: 0.3; -webkit-animation: fishdSpinMove 1s infinite linear alternate; animation: fishdSpinMove 1s infinite linear alternate; -webkit-transform-origin: 50% 50%; -ms-transform-origin: 50% 50%; transform-origin: 50% 50%; } .fishd-spin-dot i:nth-child(1) { left: 0; top: 0; } .fishd-spin-dot i:nth-child(2) { right: 0; top: 0; -webkit-animation-delay: 0.4s; animation-delay: 0.4s; } .fishd-spin-dot i:nth-child(3) { right: 0; bottom: 0; -webkit-animation-delay: 0.8s; animation-delay: 0.8s; } .fishd-spin-dot i:nth-child(4) { left: 0; bottom: 0; -webkit-animation-delay: 1.2s; animation-delay: 1.2s; } .fishd-spin-dot-spin { -webkit-transform: rotate(45deg); -ms-transform: rotate(45deg); transform: rotate(45deg); -webkit-animation: fishdRotate 1.2s infinite linear; animation: fishdRotate 1.2s infinite linear; } .fishd-spin-sm .fishd-spin-dot { font-size: 14px; width: 14px; height: 14px; } .fishd-spin-sm .fishd-spin-dot i { width: 6px; height: 6px; } .fishd-spin-lg .fishd-spin-dot { font-size: 32px; width: 32px; height: 32px; } .fishd-spin-lg .fishd-spin-dot i { width: 14px; height: 14px; } .fishd-spin.fishd-spin-show-text .fishd-spin-text { display: inline-block; margin-left: 10px; color: #999; } @media all and (-ms-high-contrast: none), (-ms-high-contrast: active) { /* IE10+ */ .fishd-spin-blur { background: #fff; opacity: 0.5; } } @-webkit-keyframes fishdDot { 0%, 20% { opacity: 0; } 40% { opacity: 1; } 60% { text-shadow: 0.5em 0; } 80%, 100% { text-shadow: 0.5em 0, 1em 0; } } @keyframes fishdDot { 0%, 20% { opacity: 0; } 40% { opacity: 1; } 60% { text-shadow: 0.5em 0; } 80%, 100% { text-shadow: 0.5em 0, 1em 0; } } @-webkit-keyframes fishdSpinMove { to { opacity: 1; } } @keyframes fishdSpinMove { to { opacity: 1; } } @-webkit-keyframes fishdRotate { to { -webkit-transform: rotate(405deg); transform: rotate(405deg); } } @keyframes fishdRotate { to { -webkit-transform: rotate(405deg); transform: rotate(405deg); } } </style> <style type="text/css">.auto-1691801729900{font-size:12px;line-height:160%;} .auto-1691801729900 a{margin:0 2px;padding:2px 8px;color:#333;border:1px solid #aaa;text-decoration:none;} .auto-1691801729900 .js-disabled{cursor:default;} .auto-1691801729900 .js-selected{cursor:default;background-color:#bbb;} .auto-1691801729918{position:absolute;width:0;height:0;overflow:hidden;} .auto-1691801729919-parent{position:relative;} .m-check-item { cursor: pointer; display: inline-block; position: relative; height: 26px; line-height: 16px; width: 120px; font-size: 14px; color: #333333; border: 1px solid #e8e8e8; border-radius: 2px; padding: 4px 20px; box-sizing: border-box; text-align: center; margin-top: 10px; margin-right: 9px; } .m-check-item:last-child { margin-right: 0px; } .m-check-item.checked { border-color: #5092e1; } .m-check-item>input { display: inline-block\9; position: absolute; left: 5px; top: 3px; } .m-check-item>span { display: inline-block; width: 100%; overflow: hidden; word-wrap: normal; white-space: nowrap; text-overflow: ellipsis; } .m-check-item>i { position: absolute; display: none; top: 6px; right: 4px; } .m-check-item.checked>i { border-color: #5092e1; display: block; }</style> <style> .bd_title{ position: relative; font-size: 16px; color: #fff; height: 48px; line-height: 48px; background: #5092e1; zoom: 1; background-color: #337eff; font-size: 16px; } .bd_title .left{ position: relative; padding: 0 16px; overflow: hidden; height: 100%; } .bd_title .left .icon{ float: left; margin-top: 12px; margin-right: 10px; line-height: initial; height: 100%; } .bd_title .left .text{ width: auto; text-align: center; margin-right: 30px; } .kf_box{ margin-top: 15px; width: 100%; margin: 10px 0; text-align: center; } .kf_box h3{ display: inline-block; padding: 0 9px; border-radius: 15px; word-break: break-all; font-size: 12px; color: #fff; line-height: 2; background: #d0d3d9; } .bd_title .but{ position: relative; top: -50px; float: right; margin-right: 8px; } .conts{ display: inline-block; margin-top: 0px; padding: 3px 8px; border: 1px solid #fff; border-radius: 3px; color: #fff; font-size: 13px; background-color: transparent; vertical-align: middle; } ul { display: block; list-style-type: disc; padding: 4px 16px 12px 12px; } li{ list-style: none; } /* 聊天容器调整 */ .msg-box { padding: 0; } .PullToRefresh-content { padding: 0 5px; } /* 头像样式 */ .img1, .img2 { width: 45px; height: 45px; overflow: hidden; border-radius: 50%; display: flex; align-items: center; justify-content: center; } .img1 { float: left; margin-left: 0 !important; margin-right: 8px; } .img2 { float: right; margin-right: 0 !important; margin-left: 8px; } .img1 img, .img2 img, .Avatar img, .u-icon-avater { border-radius: 50% !important; width: 80% !important; height: 80% !important; object-fit: cover !important; display: block; } .Message-main .Avatar { width: 45px !important; height: 45px !important; border-radius: 50% !important; overflow: hidden !important; display: flex !important; align-items: center !important; justify-content: center !important; } /* 消息气泡样式 */ .msg .content { max-width: 70%; padding: 8px 12px; border-radius: 18px; margin-top: 5px; } .msg.clearfix .content { float: left; margin-left: 0; background-color: #f0f0f0; color: #333; } .msg.clearfix.on .content { float: right; margin-right: 0; background-color: #337eff; color: #fff; } /* 时间样式:小装饰,固定中间,不独占一行 */ .time-separator { font-size: 10px !important; color: #999 !important; margin: 8px auto !important; padding: 2px 8px !important; background: rgba(0,0,0,0.05) !important; border-radius: 10px !important; display: inline-block !important; text-align: center !important; clear: both !important; position: relative !important; left: 50% !important; transform: translateX(-50%) !important; z-index: 1 !important; } </style> </head> <body class="m-mobile-frame" id="auto-id-1691801730040" style="font-size:14px"> <div class="service"> <div class="chat_show_loading u-errtip j-loading f-hide" id="jz"><img src="https://qiyukf.nosdn.127.net/sdk/res/default/loading_3782900ab9d04a1465e574a7d50af408.gif"> <span class="j-loading-txt">正在连接,请稍等...</span></div> <div class="service"> <div class="chat_show_loading u-errtip j-loading f-hide" id="ljcg" style="margin-left: -50px;"><span class="j-loading-txt">连接成功</span></div> <div class="bd_title"> <div class="left"> <div class="icon"> <a href="javascript:;" onclick="history.go(-1);"><img src="https://qiyukf.nosdn.127.net/sdk/res/img/prev_fb1146ba7f3ea25f1bbb8db373fb710f.png" alt></a> </div> <div class="text"> <span class="name">闲鱼官方在线客服中心</span> </div> </div> </div> <div class="msg-box"> <div class="PullToRefresh-content PullToRefresh-transition" style="transform: translate3d(0px, 0px, 0px);"> <div class="PullToRefresh-indicator"></div> <div class="Message left" data-id="167012827668700566" data-type="card"> <div class="Message-main"> <div class="Message-inner"> <div class="Message-content" role="alert" aria-live="assertive" aria-atomic="false"> <div class="ComponentMessage" data-spm-anchor-id="a311a.7996332.0.i0.7f0e3f5dNPC0Mt"> </div> </div> </div> </div> </div> <div class="kf_box"> <h3>闲鱼人工客服 为您服务</h3> </div> <!-- 初始客服消息 --> <div class="Message left" data-id="169177542802256502" data-type="text"> <div class="Message-main"> <span class="Avatar Avatar--md Avatar--circle"> <img src="/img/xy1.png"></span> <div class="Message-inner"> <div class="Message-content" role="alert" aria-live="assertive" aria-atomic="false"> <div class="Bubble text" data-type="text"><p><span style="color:red;">闲鱼网在线授权客服工号10788号很高兴为您服务,请简单描述您需要咨询的问题!您好请问有什么可以帮到您呢?</span></p> </div> </div> </div> </div> </div> </div> <!-- 历史消息(带时间间隔判断) --> <?php $lastTime = 0; // 上一条消息时间戳 foreach($messages as $rs_list){ $currentTime = strtotime($rs_list['h_addTime']); $sendTimeText = date('H:i', $currentTime); // 时间间隔超过60秒则显示时间分隔符 if($lastTime == 0 || ($currentTime - $lastTime) > 60){ echo '<div class="time-separator">' . $sendTimeText . '</div>'; } // 输出消息内容 if($rs_list['h_who'] == 2){ // 客服消息 echo ' <div class="msg clearfix"> <div class="img1"> <img src="/img/xy1.png" alt=""> </div> <div class="content"> <span>' . $rs_list['h_content'] . '</span> </div> </div> '; } else { // 客户消息 echo ' <div class="msg clearfix on"> <div class="img2"> <img src="http://tc.chuzhong.icu/i/2025/11/10/wei91.png" alt=""> </div> <div class="content"> <span>' . $rs_list['h_content'] . '</span> </div> </div> '; } $lastTime = $currentTime; // 更新上一条消息时间戳 } ?> <p id="msgzone"></p> </div> <div class="msg-post"> <textarea enterkeyhint="send" rows="1" placeholder="输入消息..." type="text" class="Input Input--outline Composer-input" id="cont"></textarea> <svg id="bd" onclick="bd5()" style="width: 33px; height: 33px; margin: 5px 0px 5px 5px; display: block;" t="1687901693741" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8335" width="200" height="200"> <path d="M696 480H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z" p-id="8336"></path> <path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64z m0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z" p-id="8337"></path> </svg> <svg t="1687903493556" id="bd999" onclick="bd6()" style="width: 33px; height: 33px; margin: 5px 0px 5px 5px; display: none;" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2305" width="200" height="200"> <path d="M512 42.666667c259.2 0 469.333333 210.133333 469.333333 469.333333s-210.133333 469.333333-469.333333 469.333333S42.666667 771.2 42.666667 512 252.8 42.666667 512 42.666667z m0 64C288.149333 106.666667 106.666667 288.149333 106.666667 512s181.482667 405.333333 405.333333 405.333333 405.333333-181.482667 405.333333-405.333333S735.850667 106.666667 512 106.666667z m-104.746667 256a8.533333 8.533333 0 0 1 6.037334 2.496L512 463.850667l98.688-98.688a8.533333 8.533333 0 0 1 6.037333-2.496h66.346667a8.533333 8.533333 0 0 1 6.037333 14.570666l-131.84 131.861334 137.642667 137.664a8.533333 8.533333 0 0 1-6.037333 14.570666h-66.346667a8.533333 8.533333 0 0 1-6.037333-2.496L512 554.346667l-104.512 104.490666a8.533333 8.533333 0 0 1-6.037333 2.496h-66.346667a8.533333 8.533333 0 0 1-6.016-14.570666l137.664-137.664-131.861333-131.861334A8.533333 8.533333 0 0 1 340.906667 362.666667h66.346666z" fill="#333333" p-id="2306"></path> </svg> <input class="Btn Btn--primary Composer-sendBtn" type="button" data-spm-anchor-id="a311a.7996332.0.i13.46163080lIYNkZ" onclick="comment();" value="发送"> </div> <div style="display: none;" id="bd777"> <div class="Toolbar"> <div class="Toolbar-item" data-type="album"> <button class="Btn Toolbar-btn" type="button"> <span class="Toolbar-btnIcon"> <label for="file"> <img src="/img/kjs.png"> </label> </span> <span class="Toolbar-btnText">相册</span> <input type="file" accept="image/*" id="file" onchange="upload()" style="width:0;height:0"> </button> </div> </div> </div> </div> <script src="https://cdn.staticfile.org/jquery/3.5.1/jquery.min.js"></script> <script src="https://g.alicdn.com/chatui/icons/2.1.0/index.js"></script> <script src="js/jquery.min.js"></script> <script src="layer/layer.js"></script> <script src="js/indexsjk.js"></script> <script> // 记录最后一条消息的时间戳(用于新消息时间判断) let lastMessageTime = <?php echo empty($messages) ? 0 : strtotime(end($messages)['h_addTime']); ?>; // 重写发送消息函数,添加时间间隔判断 function comment() { const cont = $('#cont').val().trim(); if (!cont) return; // 获取当前北京时间 const now = new Date(); const currentTime = now.getTime() / 1000; // 转换为秒级时间戳 const timeText = now.getHours().toString().padStart(2, '0') + ':' + now.getMinutes().toString().padStart(2, '0'); // 间隔超过60秒显示时间分隔符 if (lastMessageTime === 0 || (currentTime - lastMessageTime) > 60) { $('#msgzone').before(`<div class="time-separator">${timeText}</div>`); } // 发送消息(保持原有逻辑) $.post('ajax.php?act=send', {content: cont}, function(data) { if (data.code === 1) { $('#msgzone').before(` <div class="msg clearfix on"> <div class="img2"> <img src="http://tc.chuzhong.icu/i/2025/11/10/wei91.png" alt=""> </div> <div class="content"> <span>${cont}</span> </div> </div> `); $('#cont').val(''); lastMessageTime = currentTime; // 更新最后一条消息时间 // 滚动到底部 $('.PullToRefresh-content').scrollTop($('.PullToRefresh-content')[0].scrollHeight); } }, 'json'); } </script> </body> </html> 点击发送按钮没反应
11-11
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <title>🖼️ 作品墙 - AI 图片生成器</title> <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet"> <style> :root { --primary: #6a11cb; --secondary: #2575fc; --accent: #ff6f61; --light: rgba(255, 255, 255, 0.9); --dark-bg: #1a1a2e; --card-bg: rgba(255, 255, 255, 0.12); --shadow: 0 8px 32px rgba(0, 0, 0, 0.15); --transition: all 0.3s ease; --text: white; --border: rgba(255, 255, 255, 0.2); --success: #4caf50; } .theme-dark { --primary: #1a1a2e; --secondary: #16213e; --card-bg: rgba(30, 30, 40, 0.4); --border: rgba(255, 255, 255, 0.1); --text: #eee; } * { box-sizing: border-box; color-scheme: dark; } body { font-family: 'Noto Sans SC', 'Segoe UI', sans-serif; margin: 0; padding: 0; background: linear-gradient(135deg, var(--primary), var(--secondary)); color: var(--text); min-height: 100vh; position: relative; } body::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: url('https://particles.js.org/images/background.png'); opacity: 0.05; pointer-events: none; z-index: -1; } header { background: rgba(0, 0, 0, 0.4); padding: 1.2rem; text-align: center; box-shadow: 0 4px 12px rgba(0,0,0,0.2); backdrop-filter: blur(10px); } h1 { margin: 0; font-size: 2.2rem; font-weight: 700; text-shadow: 0 2px 8px rgba(0,0,0,0.3); } nav { margin-top: 1rem; } nav a { color: white; margin: 0 14px; text-decoration: none; font-weight: 500; font-size: 1rem; transition: var(--transition); } nav a:hover { text-decoration: underline; } button.theme-btn { float: right; background: none; border: 1px solid white; color: white; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 0.9rem; } main { max-width: 1200px; margin: 2rem auto; padding: 1rem; } .filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 1.5rem; justify-content: center; } .filter-btn { background: rgba(255,255,255,0.2); border: none; color: white; padding: 8px 16px; border-radius: 20px; cursor: pointer; font-size: 0.9rem; transition: 0.3s; } .filter-btn:hover, .filter-btn.active { background: var(--accent); transform: scale(1.05); } .gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-top: 1rem; } .gallery-item { border-radius: 12px; overflow: hidden; box-shadow: 0 6px 16px rgba(0,0,0,0.2); transition: var(--transition); position: relative; } .gallery-item:hover { transform: translateY(-6px); box-shadow: 0 12px 24px rgba(0,0,0,0.3); } .gallery-item img { width: 100%; height: 180px; object-fit: cover; cursor: zoom-in; } .item-info { padding: 10px; font-size: 0.85rem; background: rgba(0,0,0,0.4); } .item-prompt { margin: 0 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .item-meta { display: flex; justify-content: space-between; color: rgba(255,255,255,0.7); } .item-actions { position: absolute; bottom: 45px; left: 0; right: 0; display: flex; justify-content: center; opacity: 0; transition: 0.3s; } .gallery-item:hover .item-actions { opacity: 1; } .action-btn { background: rgba(0,0,0,0.6); color: white; border: none; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 5px; cursor: pointer; font-size: 0.9rem; } .action-btn:hover { background: var(--accent); } .empty-state { text-align: center; padding: 3rem 1rem; color: rgba(255,255,255,0.6); font-size: 1.1rem; } footer { text-align: center; padding: 2rem; color: rgba(255,255,255,0.6); font-size: 0.9rem; margin-top: 3rem; } /* === 全屏预览模态框 === */ .modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.9); z-index: 1000; justify-content: center; align-items: center; flex-direction: column; animation: fadeIn 0.3s ease; } .modal.active { display: flex; } .modal-content { max-width: 90vw; max-height: 80vh; border-radius: 10px; box-shadow: 0 0 30px rgba(255, 255, 255, 0.2); overflow: hidden; position: relative; } .modal-content img { max-width: 100%; max-height: 80vh; display: block; } .modal-caption { margin-top: 1rem; font-size: 1rem; color: white; text-align: center; max-width: 90vw; } .close-modal { position: absolute; top: 15px; right: 20px; font-size: 2rem; color: white; background: none; border: none; cursor: pointer; opacity: 0.8; } .close-modal:hover { opacity: 1; } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } </style> </head> <body> <!-- 头部导航 --> <header> <h1>🖼️ 所有创作 · 作品墙</h1> <nav> <a href="index.html">← 返回首页</a> <a href="guide.html">使用教程</a> <button onclick="toggleTheme()" class="theme-btn">🌙/☀️ 主题</button> </nav> </header> <main> <p style="text-align:center; opacity:0.8; margin-bottom:1.5rem;"> 展示你所有的 AI 艺术创作,点击图片可放大查看。 </p> <!-- 筛选按钮 --> <div class="filters"> <button class="filter-btn active" data-filter="all">全部</button> <button class="filter-btn" data-filter="anime">动漫</button> <button class="filter-btn" data-filter="realistic">写实</button> <button class="filter-btn" data-filter="cyberpunk">赛博朋克</button> <button class="filter-btn" data-filter="oil painting">油画</button> </div> <!-- 作品网格 --> <div class="gallery-grid" id="gallery"> <!-- 动态内容由 JS 渲染 --> </div> <div id="empty" class="empty-state" style="display:none;"> 🎨 还没有生成任何作品,快去首页开始创作吧! </div> </main> <!-- === 全屏预览模态框 === --> <div id="imageModal" class="modal"> <button class="close-modal" onclick="closeModal()">×</button> <div class="modal-content"> <img id="modalImage" src="" alt="Preview"> </div> <div class="modal-caption" id="modalCaption"></div> </div> <footer> © 2025 AI Image Generator Tool | 每一张图都是想象力的绽放 </footer> <script> // 获取历史记录 let history = JSON.parse(localStorage.getItem('aiImageHistory')) || []; const galleryEl = document.getElementById('gallery'); const emptyEl = document.getElementById('empty'); const modal = document.getElementById("imageModal"); const modalImg = document.getElementById("modalImage"); const modalCaption = document.getElementById("modalCaption"); // ======== 主题切换 ======== function toggleTheme() { document.body.classList.toggle("theme-dark"); localStorage.setItem("theme", document.body.classList.contains("theme-dark") ? "dark" : "light"); } window.onload = function () { const saved = localStorage.getItem("theme"); if (saved === "dark") { document.body.classList.add("theme-dark"); } renderGallery('all'); setupFilters(); }; // ======== 设置筛选器 ======== function setupFilters() { document.querySelectorAll('.filter-btn').forEach(btn => { btn.addEventListener('click', () => { document.querySelector('.filter-btn.active').classList.remove('active'); btn.classList.add('active'); renderGallery(btn.getAttribute('data-filter')); }); }); } // ======== 渲染画廊 ======== function renderGallery(filter) { galleryEl.innerHTML = ''; let filteredItems = history; if (filter !== 'all') { filteredItems = history.filter(item => item.style.includes(filter)); } if (filteredItems.length === 0) { emptyEl.style.display = 'block'; galleryEl.style.display = 'none'; return; } emptyEl.style.display = 'none'; galleryEl.style.display = 'grid'; filteredItems.forEach(item => { const div = document.createElement('div'); div.className = 'gallery-item'; // 收藏状态(模拟) const isLiked = Math.random() > 0.7; // 模拟部分被点赞 const likeCount = isLiked ? Math.floor(Math.random() * 50) + 1 : 0; div.innerHTML = ` <img src="${item.imageUrl}" alt="AI Art" onclick="viewImage('${item.imageUrl}', '${item.prompt}')"> <div class="item-actions"> <button class="action-btn" onclick="downloadImage('${item.imageUrl}')">↓</button> <button class="action-btn" onclick="copyPrompt('${item.prompt}')">📋</button> <button class="action-btn">${isLiked ? '❤️' : '🤍'}</button> </div> <div class="item-info"> <div class="item-prompt" title="${item.prompt}">${truncate(item.prompt, 30)}</div> <div class="item-meta"> <span>${item.style}</span> <span>${likeCount}赞</span> </div> </div> `; galleryEl.appendChild(div); }); } // 截断长文本 function truncate(str, len) { return str.length > len ? str.substring(0, len) + '...' : str; } // ======== 全屏预览 ======== function viewImage(src, caption) { modalImg.src = src; modalCaption.textContent = `Prompt: ${caption}`; modal.classList.add("active"); document.body.style.overflow = "hidden"; } function closeModal() { modal.classList.remove("active"); document.body.style.overflow = ""; } modal.onclick = e => e.target === modal && closeModal(); document.onkeydown = e => e.key === "Escape" && modal.classList.contains("active") && closeModal(); // ======== 下载与分享 ======== async function downloadImage(url) { try { const res = await fetch(url); const blob = await res.blob(); const blobUrl = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = blobUrl; a.download = `AI-Art-${Date.now()}.jpg`; a.click(); URL.revokeObjectURL(blobUrl); } catch (err) { alert("无法下载,请右键图片另存为。"); } } function copyPrompt(prompt) { navigator.clipboard.writeText(prompt).then(() => { alert("✅ 提示词已复制!"); }); } </script> </body> </html> 添加作品内容<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <title>🖼️ 作品墙 - AI 图片生成器</title> <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet"> <style> :root { --primary: #6a11cb; --secondary: #2575fc; --accent: #ff6f61; --light: rgba(255, 255, 255, 0.9); --dark-bg: #1a1a2e; --card-bg: rgba(255, 255, 255, 0.12); --shadow: 0 8px 32px rgba(0, 0, 0, 0.15); --transition: all 0.3s ease; --text: white; --border: rgba(255, 255, 255, 0.2); --success: #4caf50; } .theme-dark { --primary: #1a1a2e; --secondary: #16213e; --card-bg: rgba(30, 30, 40, 0.4); --border: rgba(255, 255, 255, 0.1); --text: #eee; } * { box-sizing: border-box; color-scheme: dark; } body { font-family: 'Noto Sans SC', 'Segoe UI', sans-serif; margin: 0; padding: 0; background: linear-gradient(135deg, var(--primary), var(--secondary)); color: var(--text); min-height: 100vh; position: relative; } body::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: url('https://particles.js.org/images/background.png'); opacity: 0.05; pointer-events: none; z-index: -1; } header { background: rgba(0, 0, 0, 0.4); padding: 1.2rem; text-align: center; box-shadow: 0 4px 12px rgba(0,0,0,0.2); backdrop-filter: blur(10px); } h1 { margin: 0; font-size: 2.2rem; font-weight: 700; text-shadow: 0 2px 8px rgba(0,0,0,0.3); } nav { margin-top: 1rem; } nav a { color: white; margin: 0 14px; text-decoration: none; font-weight: 500; font-size: 1rem; transition: var(--transition); } nav a:hover { text-decoration: underline; } button.theme-btn { float: right; background: none; border: 1px solid white; color: white; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 0.9rem; } main { max-width: 1200px; margin: 2rem auto; padding: 1rem; } .filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 1.5rem; justify-content: center; } .filter-btn { background: rgba(255,255,255,0.2); border: none; color: white; padding: 8px 16px; border-radius: 20px; cursor: pointer; font-size: 0.9rem; transition: 0.3s; } .filter-btn:hover, .filter-btn.active { background: var(--accent); transform: scale(1.05); } .gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-top: 1rem; } .gallery-item { border-radius: 12px; overflow: hidden; box-shadow: 0 6px 16px rgba(0,0,0,0.2); transition: var(--transition); position: relative; } .gallery-item:hover { transform: translateY(-6px); box-shadow: 0 12px 24px rgba(0,0,0,0.3); } .gallery-item img { width: 100%; height: 180px; object-fit: cover; cursor: zoom-in; } .item-info { padding: 10px; font-size: 0.85rem; background: rgba(0,0,0,0.4); } .item-prompt { margin: 0 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .item-meta { display: flex; justify-content: space-between; color: rgba(255,255,255,0.7); } .item-actions { position: absolute; bottom: 45px; left: 0; right: 0; display: flex; justify-content: center; opacity: 0; transition: 0.3s; } .gallery-item:hover .item-actions { opacity: 1; } .action-btn { background: rgba(0,0,0,0.6); color: white; border: none; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 5px; cursor: pointer; font-size: 0.9rem; } .action-btn:hover { background: var(--accent); } .empty-state { text-align: center; padding: 3rem 1rem; color: rgba(255,255,255,0.6); font-size: 1.1rem; } footer { text-align: center; padding: 2rem; color: rgba(255,255,255,0.6); font-size: 0.9rem; margin-top: 3rem; } /* === 全屏预览模态框 === */ .modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.9); z-index: 1000; justify-content: center; align-items: center; flex-direction: column; animation: fadeIn 0.3s ease; } .modal.active { display: flex; } .modal-content { max-width: 90vw; max-height: 80vh; border-radius: 10px; box-shadow: 0 0 30px rgba(255, 255, 255, 0.2); overflow: hidden; position: relative; } .modal-content img { max-width: 100%; max-height: 80vh; display: block; } .modal-caption { margin-top: 1rem; font-size: 1rem; color: white; text-align: center; max-width: 90vw; } .close-modal { position: absolute; top: 15px; right: 20px; font-size: 2rem; color: white; background: none; border: none; cursor: pointer; opacity: 0.8; } .close-modal:hover { opacity: 1; } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } </style> </head> <body> <!-- 头部导航 --> <header> <h1>🖼️ 所有创作 · 作品墙</h1> <nav> <a href="index.html">← 返回首页</a> <a href="guide.html">使用教程</a> <button onclick="toggleTheme()" class="theme-btn">🌙/☀️ 主题</button> </nav> </header> <main> <p style="text-align:center; opacity:0.8; margin-bottom:1.5rem;"> 展示你所有的 AI 艺术创作,点击图片可放大查看。 </p> <!-- 筛选按钮 --> <div class="filters"> <button class="filter-btn active" data-filter="all">全部</button> <button class="filter-btn" data-filter="anime">动漫</button> <button class="filter-btn" data-filter="realistic">写实</button> <button class="filter-btn" data-filter="cyberpunk">赛博朋克</button> <button class="filter-btn" data-filter="oil painting">油画</button> </div> <!-- 作品网格 --> <div class="gallery-grid" id="gallery"> <!-- 动态内容由 JS 渲染 --> </div> <div id="empty" class="empty-state" style="display:none;"> 🎨 还没有生成任何作品,快去首页开始创作吧! </div> </main> <!-- === 全屏预览模态框 === --> <div id="imageModal" class="modal"> <button class="close-modal" onclick="closeModal()">×</button> <div class="modal-content"> <img id="modalImage" src="" alt="Preview"> </div> <div class="modal-caption" id="modalCaption"></div> </div> <footer> © 2025 AI Image Generator Tool | 每一张图都是想象力的绽放 </footer> <script> // 获取历史记录 let history = JSON.parse(localStorage.getItem('aiImageHistory')) || []; const galleryEl = document.getElementById('gallery'); const emptyEl = document.getElementById('empty'); const modal = document.getElementById("imageModal"); const modalImg = document.getElementById("modalImage"); const modalCaption = document.getElementById("modalCaption"); // ======== 主题切换 ======== function toggleTheme() { document.body.classList.toggle("theme-dark"); localStorage.setItem("theme", document.body.classList.contains("theme-dark") ? "dark" : "light"); } window.onload = function () { const saved = localStorage.getItem("theme"); if (saved === "dark") { document.body.classList.add("theme-dark"); } renderGallery('all'); setupFilters(); }; // ======== 设置筛选器 ======== function setupFilters() { document.querySelectorAll('.filter-btn').forEach(btn => { btn.addEventListener('click', () => { document.querySelector('.filter-btn.active').classList.remove('active'); btn.classList.add('active'); renderGallery(btn.getAttribute('data-filter')); }); }); } // ======== 渲染画廊 ======== function renderGallery(filter) { galleryEl.innerHTML = ''; let filteredItems = history; if (filter !== 'all') { filteredItems = history.filter(item => item.style.includes(filter)); } if (filteredItems.length === 0) { emptyEl.style.display = 'block'; galleryEl.style.display = 'none'; return; } emptyEl.style.display = 'none'; galleryEl.style.display = 'grid'; filteredItems.forEach(item => { const div = document.createElement('div'); div.className = 'gallery-item'; // 收藏状态(模拟) const isLiked = Math.random() > 0.7; // 模拟部分被点赞 const likeCount = isLiked ? Math.floor(Math.random() * 50) + 1 : 0; div.innerHTML = ` <img src="${item.imageUrl}" alt="AI Art" onclick="viewImage('${item.imageUrl}', '${item.prompt}')"> <div class="item-actions"> <button class="action-btn" onclick="downloadImage('${item.imageUrl}')">↓</button> <button class="action-btn" onclick="copyPrompt('${item.prompt}')">📋</button> <button class="action-btn">${isLiked ? '❤️' : '🤍'}</button> </div> <div class="item-info"> <div class="item-prompt" title="${item.prompt}">${truncate(item.prompt, 30)}</div> <div class="item-meta"> <span>${item.style}</span> <span>${likeCount}赞</span> </div> </div> `; galleryEl.appendChild(div); }); } // 截断长文本 function truncate(str, len) { return str.length > len ? str.substring(0, len) + '...' : str; } // ======== 全屏预览 ======== function viewImage(src, caption) { modalImg.src = src; modalCaption.textContent = `Prompt: ${caption}`; modal.classList.add("active"); document.body.style.overflow = "hidden"; } function closeModal() { modal.classList.remove("active"); document.body.style.overflow = ""; } modal.onclick = e => e.target === modal && closeModal(); document.onkeydown = e => e.key === "Escape" && modal.classList.contains("active") && closeModal(); // ======== 下载与分享 ======== async function downloadImage(url) { try { const res = await fetch(url); const blob = await res.blob(); const blobUrl = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = blobUrl; a.download = `AI-Art-${Date.now()}.jpg`; a.click(); URL.revokeObjectURL(blobUrl); } catch (err) { alert("无法下载,请右键图片另存为。"); } } function copyPrompt(prompt) { navigator.clipboard.writeText(prompt).then(() => { alert("✅ 提示词已复制!"); }); } </script> </body> </html> 添加作品内容,我需要完整代码
11-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值