can somebody help me with this directory issues. I have index.php page and have included header and footer.php header contains the <link href="new.css"/>, the new.css is located in the main directory. and everytime I try to separate the new.css from the main directory like css/new.css it is not working well on other elements but if I try to put it back to the main directory it works fine . can someone tell me why is that happening?
Example:
You have a file: http://mysite.com/blabla/blabla2/index.php
Now if you use: <link href="new.css"/> - it's same like <link href="http://mysite.com/blabla/blabla2/new.css"/>
So you need use this: <link href="css/new.css"/>
try to use <link href="../css/new.css" /> this might work.
Related
Currently, I have a jsp file that I am redirecting to from index.jsp to jsp/home.jsp
The import is something like this.
<link rel="stylesheet" type="text/css" href="../bootstrap/css/bootstrap.css">
the location of the above file is
webcontent/bootstrap/css/bootstrap.css
However, if I try to click on a link to jsp/signIn.jsp, I get file not found on the css file.
I am not sure why home.jsp is behaving like it is in webcontent folder when it is in webcontent/jsp
Is there a way to work around the issue?
Try this (with JSTL tag):
<link rel="stylesheet" type="text/css" href="<c:url value="/bootstrap/css/bootstrap.css"/>">
Got around the problem. Had to use the context path as supposed to using the relative path.
I didnt need to deal with having the behaviour of the file at all.
Guess thats the answer.
Use Context Path!!
I have the following folders projectCss and inside it i have the folder languageReference,*css* and js.Inside the css folder i have the file style.css.
Inside the languageReference i have the three folders namely iframes,*docs* and cssFiles.Inside the iframes folder,i have the folders codeSamples and htmlFiles.Inside the htmlFiles folder,i have a html file called index.html.
My project setup looks like this visually.
projectCss
*css - style.css
*langugeReference
*docs
*cssFiles
*iframes
*codeSamples
*htmlFiles
*index.html
I am trying to figure out how my path will look like but nothing works.Can i get the path without resulting to serving the page on a web server?.
As Charlie said in the comments, you need to go "up" three folders (../../../) then select the folder and file like so:
<link href="../../../css/style.css" ... />
Alternatively, you could go from the "root", assuming your layout is the root, the following would work too:
<link href="/css/style.css" ... />
Use relative paths :
<link rel="stylesheet" type="text/css" href="../../../css/style.css">
i'm using MAMP on my MacBook Pro as a local server. PHP and MySql are running fine. However, i have a strange issue with CakePHP - CSS only works on homepage of my site and only by the two following paths:
'localhost' and 'localhost/index.php'
Using 'localhost/index.php/' however returns just the bare unstyled markup as does all other pages in the site. How can a slash a the end break the CSS?
A few searches have suggested this could possibly be a mod rewrite issue in apache, but i'm out of my depth to be honest - i don't know how to test if changes i make turn mod rewrite on.
As CSS works only for 2 specific paths, could it perhaps be a problems with my routes? I only have 2 defined - '/' and '/index.php/' - and they are both the same.
Any help will be greatly appreciated,
James
It looks like your MAMP configuration (or Apache within MAMP has mod_rewrite disabled. It looks like you have to follow http://documentation.mamp.info/en/mamp-pro/advanced-functions/edit-configuration-files instructions, edit template for apache's httpd.conf, search for mod_rewrite and uncomment this line in config template.
The problem is most likely as tbwcf says that you're trying to load the CSS files using relative file paths, but you should always use CakePHP's helpers to add resource files to the layout:
<?php echo $this->Html->css('style'); ?>
The above will output
<link rel="stylesheet" type="text/css" href="/css/style.css" />
The benefit is that if you install the app to some other directory the path changes automatically:
<link rel="stylesheet" type="text/css" href="/other/directory/css/style.css" />
Do not use relative file paths like ../css. It will break the layout again in all but the simplest cases.
The slash at the end of the markup is most likely breaking the file path to your stylesheet. For example if your css is referenced as
<link rel="stylesheet" href="css/stylesheet.css" />
then adding the slash to the page URL would mean you'd need to jump back a step to get to the same stylesheet as it would no longer be in the same folder as the page you're on.
So you could add
../ before the reference like <link rel="stylesheet" href="../css/stylesheet.css" />
Or possibly an easier solution in this case would be to reference your stylesheet absolutely like:
<link rel="stylesheet" href="http://localhost:8888/project/css/stylesheet.css" />
I am new to the domain. I want to include a CSS file in my master pages,but it is not working can anyone try to help me out of this problem..
I give the link to the CSS externally as
<link href="Stylesheet1.css" rel="Stylesheet1" type="text/css" />
Is there any necessity to include CSS classes in master page if so how and where I have to include?
Try:
<link href="~/Stylesheet1.css" rel="Stylesheet1" type="text/css" />
Tilde (~) represent root directory.
If this doesn't work, if you can show us your directory structure, and look at the rendered source we can help more.
You can of course not use the Tilde (~) on tags that are not run server-side, what you have to do is something like this:
<link href="<%= ResolveClientUrl("~/Stylesheet1.css")%>" rel="stylesheet" type="text/css" />
Or just do a method that gives you back a full link-tag.
There's nothing wrong with the syntax of your <link> tag. The problem is likely to be caused by the fact that your CSS file isn't located at the URL you're attempting to get it from.
The href attribute in your markup specifies a file called Stylesheet1.css in the same folder as your master page. If its not you should specify the location of the stylesheet using standard, virtual path or move the stylesheet to the same folder as your masterpage.
More info.
http://w3schools.com/css/css_howto.asp
In the root of my domain i have the CSS file style.css and the masterpage file site.master.
The link to the CSS file within the site.master is
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
The problem is that webpages contained within subdirectories do not inherit the CSS file.
What am i doing wrong here?
If i copy the style.css file to the subdirectories everything works like a charm...
UPDATE: If i change the path to /style.css or to ~/style.css the style is Not applied also to the webpages within the root folder.
MasterPages use the containing page for the path.
change your css tag to be a server control and use the "~" root symbol.
<link id="lnkStyle" runat="server" href="~/style.css"
rel="stylesheet" type="text/css" />
You need to specify the path as /style.css.
Well the obvious question is, does the other pages inherit the correct masterpage, namely the one with your css link?
ie.
<%# Page Language="C#" MasterPageFile="~/MasterPage.master"...
also perhaps '/' before file name would help
If you're including that link tag in your master page, the HTML being output by the content pages in subdirectories contains a link to "style.css", which the browser looks for in that directory.
If you're developing in ASP.NET, you should be placing your CSS files in themes, which will take care of this problem. If you really don't want to do that for some reason, make the URL to the stylesheet an application-relative path ("~/style.css") and make the link tag executed on the server; I believe that that will resolve the application path and generate an absolute URL.
Try this:
<link href="<%: Url.Content("~/style.css") %> rel="stylesheet" type="text/css" media="screen" />
It will make the path relative to your hostname, giving the correct path to your pages in the subdirectories. Right now, just linking style.css gives it the folder relative path, so its looking inside of the same folder your page is in, instead of where you intended. Hope that helps. You could also re-write your link with a preceding forward slash, like "/style.css" and that should also do the trick.