【问题标题】:Image size in css for php images loading from a file用于从文件加载的 php 图像的 css 中的图像大小
【发布时间】:2019-01-30 11:28:25
【问题描述】:

我正在尝试添加 css 代码来处理从文件源自动加载的图像大小。我正在使用 php scrpt 加载图像并且它正在工作,但我无法使用 css 为响应式站点更改图像的大小。我正在使用砖石来显示图像,这又是有效的。

我正在展示正在运行的 php。我需要帮助来处理 .project 中图像的大小

                   <div class='project'>


        <?php 
        // Image extensions
        $image_extensions = array("png","jpg","jpeg","gif");

        // Target directory
        $dir = 'img/';
        if (is_dir($dir)){

            if ($dh = opendir($dir)){
                $count = 1;

                // Read files
                while (($file = readdir($dh)) !== false){

                    if($file != '' && $file != '.' && $file != '..'){


                        // Image path
                        $image_path = "img/".$file;


                        $image_ext = pathinfo($image_path, PATHINFO_EXTENSION);

                        // Check its not folder and it is image file
                        if(!is_dir($image_path) && 

                            in_array($image_ext,$image_extensions)){
                            ?>

                            <!-- Image -->

                                <img src="<?php echo $image_path; ?>" alt="" title=""/>
                            </a>
                            <!-- --- -->
                            <?php

                        }
                    }

                }
                closedir($dh);
            }
        }
        ?>
        </div>

【问题讨论】:

    标签: php html css


    【解决方案1】:

    Css不能对图片进行mainpulate,只能添加样式(例如,比他的父级一半大小,20%的亮度,蓝色边框等)但是你不能操作它。

    用于在 Google 中进行此搜索的脚本,用于在 PHP 中调整图像大小或剪切图像。但是在砌体中这没有任何意义,砌体的魔力是使任何尺寸适应任何布局(通过 Javascript)。

    【讨论】:

    • 我不同意 CSS - 样式是一种操作形式,因此在某种意义上 CSS 可以操作图像,尽管操作形式非常有限。一些浏览器通过 CSS 支持反转图像颜色。但不是全部
    • 是的,但是这个操作是在图像之上的一层,换句话说,你不能对原始图像进行操作(比如剪切它)
    • 一个可悲的事实是 =),很难说出 OP 到底需要什么——从外观上看,css 应该足够了。 OP 的代码根本没有显示 CSS。 =)
    猜你喜欢
    • 1970-01-01
    • 2018-11-17
    • 2012-10-19
    • 1970-01-01
    • 2016-08-20
    • 1970-01-01
    • 1970-01-01
    • 2020-10-22
    • 1970-01-01
    相关资源
    最近更新 更多