douyin6188
2016-02-13 19:34
浏览 51
已采纳

如何在XAMPP中更改我的目录根目录

I'm using XAMPP and my root is C:/xampp/htdocs. Firstly, I will list my files:

I have index.php file on htdocs/public I have theme.css file on htdocs/public/css

I'm trying to link my css file to my html file like this:

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

But it doesn't work. When I right click to the browser and select "view source", and when I click to the href="/css/theme.css", it goes to this direction: http://localhost:8080/css/theme.css

But I want to make it go to this direction: http://localhost:8080/public/css/theme.css

How can I make this happen?

图片转代码服务由CSDN问答提供 功能建议

我正在使用XAMPP,我的root是C:/ xampp / htdocs。 首先,我将列出我的文件:

我在htdocs / public上有index.php文件 我在htdocs / public / css上有theme.css文件

我正在尝试将我的css文件链接到我的html文件,如下所示:

 &lt; link rel =“stylesheet”href =“/ css / theme.css  “type =”text / css“&gt; 
   
 
 

但它不起作用。 当我右键单击浏览器并选择“查看源代码”时,当我点击href =“/ css / theme.css”时,它会转到这个方向: http:// localhost:8080 / css / theme.css

但我想让它去 这个方向: http:// localhost:8080 / public / css / theme.css

如何实现这一目标?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • duanjinchen5296 2016-02-13 19:43
    已采纳

    You have to indicate your current directory to include the css file, like this:

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

    Here, ./ indicates the current directory.

    Or, you can specify the file path relative to the root directory like this:

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

    Or, you can just remove this /public/ altogether and include your css file like this:

    <link rel="stylesheet" href="css/theme.css" type="text/css">
    
    点赞 打赏 评论
  • douchibu7040 2016-02-13 19:40

    The most straightforward way is:

    <link rel="stylesheet" href="public/css/theme.css" type="text/css">
    
    点赞 打赏 评论

相关推荐 更多相似问题