php - 删除图像图标对齐

标签 php jquery css icons fancybox

我想知道是否有人可以帮助我。

使用下面的脚本,我正在用 fancyBox 创建一个图像库。

<!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>  
  <title>Gallery</title>  
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />  
    <script type="text/javascript" src="fancybox/lib/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="fancybox/source/jquery.fancybox.js?v=2.0.6"></script>
    <script type="text/javascript" src="fancybox/source/helpers/jquery.fancybox-buttons.js?v=1.0.2"></script>
    <script type="text/javascript" src="fancybox/source/helpers/jquery.fancybox-thumbs.js?v=1.0.2"></script>
    <script type="text/javascript" src="fancybox/source/helpers/jquery.fancybox-media.js?v=1.0.0"></script>
    <link rel="stylesheet" type="text/css" href="fancybox/source/helpers/jquery.fancybox-thumbs.css?v=1.0.2" />
    <link rel="stylesheet" type="text/css" href="fancybox/source/helpers/jquery.fancybox-buttons.css?v=1.0.2" />
    <link rel="stylesheet" type="text/css" href="fancybox/source/jquery.fancybox.css?v=2.0.6" media="screen" />


  <script type="text/javascript">  

            $('.fancybox').fancybox({
                openEffect  :   'elastic',
                closeEffect :   'elastic',

                padding :   20,
                fitToView   :   true,

                prevEffect :    'none',
                nextEffect :    'none',

                closeBtn  : false,
                arrows : false,

                helpers : {
                    title : {
                        type : 'inside'
                    },
                    buttons : {}
                },

                afterLoad : function() {
                    this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : '');
                }
            });


</script> 


  <style type="text/css">
<!--
.style1 {
    font-size: 14px;
    margin-top: 5px;
    margin-right: 110px;
}
-->
  </style>  
</head>
<body style="font-family: Calibri; color:  #505050; margin-left: 240px; float:left;"/>
<div align="right" class="style1"> <a href = "javascript:document.gallery.submit()"/> Add Images <a/> &larr; View Uploaded Images </div> 
  <form id="gallery" name="gallery" class="page" action="index.php" method="post" style="margin-left: -120px; margin-right: 50px; border-left: 100;"> 

    <p>
      <?php for ($i = 0; $i < $descriptions->documentElement->childNodes->length; $i++) :  
                          $xmlFile = $descriptions->documentElement->childNodes->item($i);  
                          $name = htmlentities($xmlFile->getAttribute('originalname'), ENT_COMPAT, 'UTF-8');  
                          $description = htmlentities($xmlFile->getAttribute('description'), ENT_COMPAT, 'UTF-8');  
                          $source = $galleryPath . rawurlencode($xmlFile->getAttribute('source'));  
                          $thumbnail = $thumbnailsPath . rawurlencode($xmlFile->getAttribute('thumbnail'));  
                  ?>
                  <img src="cross.png" class="removeImage" alt="Remove this image" align="top"/> 
        <a class="fancybox" rel="allimages" title="<?php echo $name; ?>" href="<?php echo $source; ?>"><img src="<?php echo $thumbnail; ?>"alt="<?php echo $description; ?>" /></a>
      <?php endfor; ?>  
    </p>
</form>  
</body>
</html> 

根据本网站上的一些建议,我为每张图片添加了一个“十字”图标,最终将用于删除图片。

我对 jQuery 和样式表等非常陌生,但我想做的是将十字放在实际图像的左上角,而不是像目前显示在div 的顶部。我在此处包含了指向相关页面的链接 here .

对于经验丰富的开发人员来说,这可能非常简单,我对此表示赞赏,但正如我所说,我只是在上周才真正开始使用 jQuery 和 CSS 文件。

我只是想知道是否有人可以就如何进行此操作提供一些指导。

非常感谢和问候

最佳答案

您必须稍微重新格式化您的 HTML 输出并添加额外的样式才能做到这一点。 因此,对于 for 循环中的每个图像,请使用以下代码:

<div style="display: inline-block; position: relative;">
    <a class="fancybox" rel="allimages" title="<?php echo $name; ?>" href="<?php echo $source; ?>">
        <img src="<?php echo $thumbnail; ?>" alt="<?php echo $description; ?>">
    </a>
    <a href="#delete" style="position: absolute; left: 0; top: 0;">
        <img src="cross.png" class="removeImage" alt="Remove this image" align="top"> 
    </a>
</div>

否则,您可以通过应用 CSS 类来实现:

.myimage {
    display: inline-block;
    position: relative;
}

.cross {
    position: absolute;
    left: 0;
    top: 0;
}

并将这些类添加到您的 HTML 标记中:

<div class="myimage">
    <a class="fancybox" rel="allimages" title="<?php echo $name; ?>" href="<?php echo $source; ?>">
        <img src="<?php echo $thumbnail; ?>" alt="<?php echo $description; ?>">
    </a>
    <a href="#delete" class="cross">
        <img src="cross.png" class="removeImage" alt="Remove this image" align="top"> 
    </a>
</div>

关于php - 删除图像图标对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10364029/

相关文章:

php - 如何在 PHP 脚本文件中安全存储用户名密码

在 MVC 的 Global.asax 文件中使用 Application_PreRequestHandlerExecute 方法时,Jquery 和 css 在服务器上不起作用

html - 如何在 IE 中按下 tab 时在文本框 (UI) 中显示全部内容

php - 菜单项不具有相同的高度

php - PHP 中的 SQL 查询,谓词位于数组中

php - 单击链接时播放声音

php - jquery:你可以在$(window).unload()中执行ajax请求吗?

javascript - 检测窗口大小 onload 以及调整大小?

jquery - 标题部分始终位于网站顶部

jquery - 在框外向左和向右移动 div