Table of Contents
Reply to discussion (solution)
Home Web Front-end HTML Tutorial Could you please tell me what is wrong with this code? _html/css_WEB-ITnose

Could you please tell me what is wrong with this code? _html/css_WEB-ITnose

Jun 24, 2016 am 11:51 AM

Special note here, I made a batch upload effect, but now I want to add a small picture with a delete cross in the upper right corner of each picture, and then click on this small picture to automatically hide it. As for deletion, I will use a program To implement. I don’t know if any hero can give me a solution, thank you

I found a css image on the Internet with a delete cross in the upper right corner, took it out and tried it, but there was a problem and the deletion was not implemented. I couldn’t see it clearly. What went wrong?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>商品列表 - <?php echo $_LANG['home'];?></title><meta name="keywords" content="" /><meta name="description" content="" /><link rel="shortcut icon" type="image/ico" href="images/favicon.ico"><style>body{	margin:0;	padding:0;	background:url(../bg.gif) 0 0 repeat #f7f5f5;	color:#333;	font-family:Cambria, Georgia, serif;	font-size:15px;	overflow-x:hidden;}a {	color:black;	text-decoration:none;}a:hover, a:active{	color:black;}/* clearfix */.clearfix {	clear:both;}/* container */#container{	position:relative;	width:1100px;	margin:0 auto 25px;	padding-bottom: 10px;}.grid{	width:188px;	min-height:100px;	padding: 15px;	background:#fff;	margin:8px;	font-size:12px;	float:left;	box-shadow: 0 1px 3px rgba(34,25,25,0.4);	-moz-box-shadow: 0 1px 3px rgba(34,25,25,0.4);	-webkit-box-shadow: 0 1px 3px rgba(34,25,25,0.4);	-webkit-transition: top 1s ease, left 1s ease;	-moz-transition: top 1s ease, left 1s ease;	-o-transition: top 1s ease, left 1s ease;	-ms-transition: top 1s ease, left 1s ease;}.border{   box-shadow: 2px 2px 3px  rgba(34,25,25,0.4) ;	-moz-box-shadow: 2px 2px 3px  rgba(34,25,25,0.4) ;	-webkit-box-shadow: 2px 2px 3px rgba(34,25,25,0.4) ;  cursor:pointer;      }.grid .closeimg{    position:absolute;	top : -25px;	right : -16px;	width : 50px;	height : 50px;	display:none;}.grid strong {	border-bottom:1px solid #ccc;	margin:10px 0;	display:block;	padding:0 0 5px;	font-size:17px;}.grid .meta{	text-align:right;	color:#777;	font-style:italic;}.grid .imgholder img{	max-width:100%;	background:#ccc;	display:block;}</style>    <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>   <script type="text/javascript">        $(document).ready(function () {            //blocksit define            $(window).load(function () {                $('#container').BlocksIt({                    numOfCol: 5,                    offsetX: 8,                    offsetY: 8                });            });            //window resize            var currentWidth = 1100;            $(window).resize(function () {                var winWidth = $(window).width();                var conWidth;                if (winWidth < 660) {                    conWidth = 440;                    col = 2                } else if (winWidth < 880) {                    conWidth = 660;                    col = 3                } else if (winWidth < 1100) {                    conWidth = 880;                    col = 4;                } else {                    conWidth = 1100;                    col = 5;                }                if (conWidth != currentWidth) {                    currentWidth = conWidth;                    $('#container').width(conWidth);                    $('#container').BlocksIt({                        numOfCol: col,                        offsetX: 8,                        offsetY: 8                    });                }            });            //鼠标划过事件            $(".grid").mouseover(function () {                $(this).addClass("border");                //显示删除叉                $(this).find(".closeimg").css("display", "block");            });            $(".grid").mouseout(function () {                $(this).removeClass("border");                //隐藏删除叉                $(this).find(".closeimg").css("display", "none");            });    });    </script></head><body><div id="container">        <div class="grid">            <img src="images/close_pop.png" class="closeimg" alt="删除商品"  />            <div class="imgholder">                <img src="images/20150104.jpg" width="175px" />            </div>            <strong>日落湖</strong>            <p>                和平日落景观......</p>            <div class="meta">                2013年6月6日</div>        </div>        <div class="grid">         <img src="images/close_pop.png" class="closeimg" alt="删除商品" width="80px" height="80px" />            <div class="imgholder">                <img src="images/20150104.jpg" />            </div>            <strong>天国的桥梁</strong>            <p>                桥在哪里?</p>            <div class="meta">                by SigitEko</div>        </div></div></body></html>
Copy after login


Reply to discussion (solution)

Or without looking at this code, does anyone know how to add a delete to the upper right corner of the image? Small pictures with crosses are best. This is what I need, because my css skills are too bad

Anyone can help, I would be very grateful

<div class="pic-show">  <img src="" />  <p>x</p></div>
Copy after login


.pic-show{margin:10px;position:relative;width:100px;height:100px;}.pic-show p{position:absolute;width:8px;height:8px;right:-8px;top:-8px;}
Copy after login

Just to add, if you want to change the P tag to an A tag, remember display:block

Hmm, I don’t know. . ,,,,,,,,,,,,,,

To add, if you want to change the P tag to the A tag, remember display:block


I want to click that If so, what should I do to hide the picture?

Can anyone take a look at the effect I achieved? Now I want to hide multiple clicks on this basis, but I can only click once

<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script><style>#pic-show{margin:15px;position:relative;width:100px;height:100px;}#pic-show p{position:absolute;width:8px;height:8px;right:-4px;top:-30px;cursor:hand;}</style><div id="pic-show">  <img src="images/20150104.jpg" width="100" height="100" />  <p class="closeimg"><img src="images/close_pop.png" width="30"></p></div><div id="pic-show">  <img src="images/20150104.jpg" width="100" height="100" />  <p class="closeimg"><img src="images/close_pop.png" width="30"></p></div><script language="javascript">$(function(){ $(".closeimg").click(function(){ $('#pic-show').remove();  });});</script>
Copy after login


$(function(){
$(".closeimg").click(function(){
$(this).parent().remove();
});
});

$(function(){
$(".closeimg").click(function(){
$(this).parent().remove( ; > .preview{width:80px;border:solid 1px #dedede; margin:10px 1px 10px 20px;padding:10px;float:left;}
#pic-show{margin:15px 15px 15px 0px;position:relative; float:left;}
#pic-show p{position:absolute;width:8px;height:8px;right:-4px;top:-30px;cursor:hand;}



html paste




$(function(){

$(".closeimg").click(function(){
$(this ;
Here is the CSS

.preview{width:80px;border:solid 1px #dedede; margin:10px 1px 10px 20px;padding:10px;float:left;}

#pic-show{margin:15px 15px 15px 0px;position:relative;float:left;}
#pic-show p{position:absolute;width:8px;height:8px;right:-4px;top:-30px;cursor:hand;}



Thank you, I solved it myself. It may be the json data output by php. I did not receive the style but only the image. I wrote the style directly in JSON

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the purpose of the <progress> element? What is the purpose of the <progress> element? Mar 21, 2025 pm 12:34 PM

The article discusses the HTML &lt;progress&gt; element, its purpose, styling, and differences from the &lt;meter&gt; element. The main focus is on using &lt;progress&gt; for task completion and &lt;meter&gt; for stati

Is HTML easy to learn for beginners? Is HTML easy to learn for beginners? Apr 07, 2025 am 12:11 AM

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

What is the purpose of the <datalist> element? What is the purpose of the <datalist> element? Mar 21, 2025 pm 12:33 PM

The article discusses the HTML &lt;datalist&gt; element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

What is the viewport meta tag? Why is it important for responsive design? What is the viewport meta tag? Why is it important for responsive design? Mar 20, 2025 pm 05:56 PM

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

What is the purpose of the <iframe> tag? What are the security considerations when using it? What is the purpose of the <iframe> tag? What are the security considerations when using it? Mar 20, 2025 pm 06:05 PM

The article discusses the &lt;iframe&gt; tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

What is the purpose of the <meter> element? What is the purpose of the <meter> element? Mar 21, 2025 pm 12:35 PM

The article discusses the HTML &lt;meter&gt; element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates &lt;meter&gt; from &lt;progress&gt; and ex

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

See all articles