If an image shows up in a div when I code:
background:url(/imgs/crowd1.jpg)
in the css, but is doesn't when I code
background:url(imgs/crowd1.jpg)
what does that indicate I am doing wrong?
/ means that it the file or folder is in the root folder while without the / means that the file or folder is in the current directory.
Here is a brief description of other file paths:
./ means the current directory
../ means the parent of the current directory, not the root directory
/ is the root directory
myfile.text is in the current directory, as is ./myfile.text
../myfile.text is one level above you and /myfile.text lives in your root directory.
Related
Trying to change the font in styles.css file in GitHub pages, here is the code:
#font-face {
font-family: "Samim";
src: url("/resources/Samim.ttf") format("truetype");
}
Here is the directory and font saved in resources folder
project files directory
the problem is that font doesn't change, also tried to move the font to main directory but no change, it also works properly locally on vscode live preview.
You have to provide the Relative Path to the file,
For Example Take This Directory Structure:
- root
- system-files
- vahid
- github-pages
- resources
- Samim.ttf
- README.md
- index.html
- styles.css
Here the "root" is the Drive On which your Operating System is Stored On, and "system-files" contains your Operating System's Important Files and finally you have this folder "vahid" which contains the user's files, and inside "vahid" you have "github-pages" folder where all your github pages code is stored.
In Path the / means the root, in Windows take this as like if you open C:\ in Windows Explorer.
And this period . means current directory, and when you use ./ instead of / you're specifying a path to a file/folder in current Directory.
Now when in my styles.css if I use this Path /resources/Samim.ttf what it means is "Samim.ttf" File in inside of the "resources" folder in the root directory.
Did you notice something? Let me try to show this path in the directory Structure.
- root
- resources
- Samim.ttf
As you can see the Path we specified doesn't exist, try to compare it to the Real Directory Structure Given Above.
So instead of using / we have to use ./ because the "resources" folder is in the same folder as of the "styles.css".
So you have to replace your Absolute Path with Relative Path, which will be this:
./resources/Samim.ttf
Read More About Relative And Absolute Path At LinuxHandBook.com
I changed the directory path like this:
url("./resources/Samim.ttf")
just added one . after /, idk why but it works now!
also trided ../resources , ..resources and /resources and didn't worked.
Docs that there is a possibility to use src folder in Next.js.
I think this is a good pattern to separate actual business logic from app configs.
It would feel natural to me to put the public folder also under the src folder.
No. The public folder has to be in root folder
Config files like next.config.js and tsconfig.json should be inside the root directory, moving them to src won't work. Same goes for the public directory
I want to generate a .zip file which contains some files and folders. The file inside the folder might be contained in some other paths and I want to put files in another folder and generate a .zip file from them.
By other words, I don't want to physically generate the folder with files. The files might be on some roots and I want to generate folder virtually to put them on the .zip file.
Imports System.IO.Compression
ZipFile.CreateFromDirectory("source","destination.zip",CompressionLevel.Optimal,False)
As an example if I have these files on my website:
- ~/files/image/1.jpg
- ~/files/pdf/2.pdf
- ~/intro.docx
I want to put them on a zip which when I extract it, the files will be as follows:
- ~/files/1.jpg
- ~/files/2.pdf
- ~/intro.docx
For the source put the root folder and it will do it
example :
This is yours
- ~/files/image/1.jpg
- ~/files/pdf/2.pdf
- ~/intro.docx
But before this there is a root folder whic is the ~ just simpily put as a source
I am building a site that has a page titled 'CSS'. So, to me, the most logical place to store the page's index.html file is in the corresponding css/ folder.
Are there any potential problems I could run into using the css/ directory as a subpage folder as well as the place I store my css/sass like i the following directory:
siteroot
css/
index.html (sub-page I am asking about)
mainstyle.css
sass/
index.html
js/
app.js
img/
example.png
It's worth pointing out I'm not using relative URLs, so I can't see file paths being an issue.
I know cwd stands for "current working directory", but what I don't understand is why is has to be included in the gruntfile.js.
Won't the script run always in the current working directory? Why would you need to change or specify another one?
grunt.js resides in the root of our project.
cwd is the path where grunt looks for the files matching the pattern in src and performs operations on. It can be an img folder in the current project root or a script folder in the current project root.
In other words, cwd is the parent folder of src files. It might not be the root folder of the root of the current project but a child of it.
Hope this helps answer your question.