简体   繁体   English

PHP CSS ::内联工作,但不包括内部和外部样式表

[英]PHP CSS :: inline work but not internal and external stylesheet

I have created PHP files which accept data from $_GET method. 我创建了PHP文件,该文件接受来自$ _GET方法的数据。

After that I use all the data I get to create HTML pages. 之后,我将使用所有数据来创建HTML页面。 Nothing is wrong with the data but in CSS I cannot style HTML elements. 数据没什么问题,但是在CSS中,我无法设置HTML元素的样式。 Except when it comes to inline styling, that works but it is not good to maintain. 除非涉及内联样式,否则该方法有效,但不好维护。

I try to use like this but it doesn't work , Please Help 我尝试使用这种方式,但是它不起作用,请帮助

THANK IN ADVANCE 预先感谢

Example.php Example.php

<?php
$dataCover      = $_GET['dataCover'];
$dataTitle      = $_GET['dataTitle'];
$dataTag        = $_GET['dataTag'];
$dataDir        = $_GET['dataDir'];
$dataYear       = $_GET['dataYear'];
$dataCreated    = $_GET['dataCreated'];
$dataModified   = $_GET['dataModified'];
$userAUID       = $_GET['userAUID'];
$galleryID      = $_GET['galleryID'];
?>

<!DOCTYPE html>
<html>
<head>
    <title></title>

    <style type="text/css" media="all">
        #container img{
            height: 230px;
            width: 200px;
        }
        #container .center{
            display: block;
            margin: 0 auto;
        }
    </style>

    <script src="../lib/jquery-1.10.2.min.js"></script>
    <script src="../lib/jquery.mobile-1.3.1.min.js"></script>
    <script src="../lib/se.js"></script>
</head>

<body>


    <div data-role ="page" id ="page1">
        <div data-role ="header">
            <h1> header </h1>
        </div>

        <div data-role="content">
            <div id="container">
                <img class="center" src="<?echo $dataCover?>" alt=""/>
                <p id="title"><?echo $dataTitle;?></p>
                <p id="tag"><?echo $dataTag;?></p>
                <p id="created">Created : <?echo $dataCreated?></p>
                <p id="modified">modified : <?echo $dataModified?></p>
                <a href="http://54.249.251.55/AUgallery"  target="_blank" data-url="<? echo $dataCreated ?>" rel="external" data-role="button">View Ebook-Gallery</a>
                <a href="<?echo 'http://localhost/webAPP/php/addBookmark.php?userAUID='.$userAUID.'&noteID='.$galleryID?>"data-ajax="false" rel="external" data-role="button">Bookmark</a>
            </div>
        </div>
    </div>

</body>
</html>

When you move your css from inline to style sheet file, you have to refresh your page with Ctrl+F5. 当将CSS从内联移动到样式表文件时,必须使用Ctrl + F5刷新页面。 Maybe it's coming from the cache. 也许它来自缓存。 Also you can assign your css to the image by jquery. 您也可以通过jquery将css分配给图像。

I dont see any reference to any external stylesheet , so it seems like you have forgotten to do this. 我看不到任何对外部样式表的引用,因此似乎您已经忘记这样做了。

Put this line 把这行

<link rel="stylesheet" type="text/css" href="/css/style.css" />

Somewhere in the head. 在头部的某个地方。 Maybe before the script tags. 也许在脚本标签之前。

Make sure you adjust the path to your stylesheet. 确保调整样式表的路径

Yes When you want to apply external css you have to  give the path after the <title> tags within the <head> tags .just follow the html code
<!DOCTYPE html>
<html>
<head>
    <title></title>

    <link rel="stylesheet" type="text/css" href="css/style.css" />
<!--Here css is the folder name where you have keep the style.css file -->

    <script src="../lib/jquery-1.10.2.min.js"></script>
    <script src="../lib/jquery.mobile-1.3.1.min.js"></script>
    <script src="../lib/se.js"></script>
</head>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM