I am working with codeigniter. But CSS is not working even I use base url() function.
< link href="< ? php echo base_url(); ?>
application/views/vehicle/css/bootstrap.min.css" rel="stylesheet" media="screen" />
If I just echo base url(), it outputs
http://localhost/codeigniter/
My css is in
C:\xampp\htdocs\codeigniter\application\views\vehicle\css
Can someone please help me with this?
Your css file should be in publicly approachable directory.
Application directory (application or APPPATH) is not publicly reachable.
So your CSS file should be somewhere next to index.php file of your application.
It is common to have assets/css path started in your website root:
-application
-system
-assets
--css
---vehicle.css
-index.php
-.htaccess
And if you make your web application code that uses CSS files dinamicaly regarding of route used, you can resolve it by adding more related subfolders:
-application
-system
-assets
--css
---vehicle
----style.css
-index.php
-.htaccess
This way, after url helper is loaded, you could reach css link with:
<?php echo base_url('assets/css/vehicle/style.css');?>
Eventualy you should include assets location in .htaccess file enabling Apache server to allow reading of it.
Maybe because of the ">" closing tag before "media".
Maybe you could try with relative path. So use as many "../" as needed to go back into parent folder untill you reach root dir (if your php file is in a sub-folder) and then add the path to the CSS file.
Related
I am trying to load CSS file in localhost but it's just showing white page. I was try to drag and drop file direct to browser and its opened. So file its not empty. and file also open when i use a server and add link to file.
I am using laravel 5.8, PHP 7.2
<link href="{{ URL::asset('css/style.css') }}" rel="stylesheet" type="text/css" media="all" />
CSS file location /public/css i am getting link in source http://localhost/css/style.css
This is most likely a file reference error. Check the markup output and compare the file URL against where it actually sits in the directory structure. If they match up, maybe a directory permissions issue?
In css links only asset is working fine... No need to include URL. so try using only asset.
I've been spending hours trying to locate where localhost's files are stored.
I've tried looking at the page source but all it tells me is http:/localhost/....
which is not what I need.
My Xampp directory (where I load Xampp control) is located in my desktop but there is no change when I alter stuff inside its htdocs.
The default root for XAMPP, assuming you installed in the default location, is c:\xampp\htdocs. You can change this by modifying the Apache configuration in c:\xampp\apache\conf\httpd.conf.
You can always check it through PHP:
echo $_SERVER["DOCUMENT_ROOT"];
Or if you want to use WordPress functions:
echo get_stylesheet_directory();
Include these codes in your page.php or header.php for example.
I have a Jekyll site with some posts and some pages in the root directory.
If I navigate to a page in the root directory, such as localhost:4000/index.html all of the files in the _includes directory load no problem using:
{% include head.html %}
If I then go to a post using the permalink format as defined in config.yml:
permalink: /:categories/:title
localhost:4000/blogpost/first-post
The include files are not loaded. Looking in Firebug at the CSS files in the header it gives an error that the file is not found and is looking in the directory:
/blogpost/first-post/css/boostrap.min.css
If I give the post a permalink in YAML as:
permalink: /first-post.html
Everything works fine.
How do I set up the include to find the right files in my pages when using permalinks to navigate?
Includes and assets are two different things.
Includes are partials that are usually stored in _includes. If include anyfile.html work in index.html, it will work in any other page or post.
assets like js, css or images are loaded by html following a path. It's better to use a path relative to the site root. That's why Jekyll calls assets like this :
<link rel="stylesheet" href="{{ "/css/main.css" | prepend: site.baseurl }}">
So, if your site is reached at http://localhost/any/path, your _config.yml look like this :
url: http://localhost
baseurl: /any/path
And then, no more problems with assets !
Situation
Use bower In .bowerrc
In bowerrc set directory vendor/assets/bower_components
In config application.rb I typed config.assets.paths << Rails.root.join('vendor', 'assets', 'bower_components')
Install gallery plugin called «fotorama», do it by bower
All files of plugin «fotorama» now storage in this directory "/vendor/assets/bower_components/fotorama"
In manifest css file application.css I type *= require fotorama/fotorama.css
In layout file I typed <%= stylesheet_link_tag "application" %>
Starting server rails server — everything is ok. In source of generated page I see <link href="/assets/fotorama/fotorama.css?body=1" rel="stylesheet" />. This css file has this line .fotorama__video-play {background: url(fotorama.png) no-repeat}, and many other lines where uses url for file "fotorama.png", and it is ok, browser try to find this png file near the css file, and successfully do it.
Stop server, precompile all essets rake assets:precompile, and then run server in production environment rails server -e production
Problem
In production, all my css files concatenated, and in source of page it looks like this <link href="/assets/application-2d31fc33890d01b046194920367eb3d4.css" rel="stylesheet" />, and still this file has this line .fotorama__video-play {background: url(fotorama.png) no-repeat}. Now browser trying to find png file here http://localhost:3000/assets/fotorama.png, but it isn't here, it isn't anywhere, because, I don't know why, there is no "fotorama.png" in "public/assets" folder.
Questions
Why pictures didn't transport from "/vendor/assets/bower_components" to "public/assets"
Have you got an idea, what can I do to solve my problem? Important, that I don't want to change urls in css manually, programatically — ok.
Excuse me for my english, and thanks for everybody who going to help me.
Solution and answers
Only files from "app/assets" transports to "public/assets" by default. To transport images from "/vendor/assets" type in "application.rb" this code config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
Task for gulp: if you see some changes in "bower.json", take all main files of bower components by npm moudle called "main-bower-files". Generate a manifest file with each css file with .erb extension, and save it "app/assets/stylesheets/bower_components_manifest.css"
This task continue: in every main css files, by npm module called "gulp-css-url-adjuster", add before every url <%= asset_path ' plus path to directory, and after ' %>. url("fotorama.png") >> url("<%= asset_path 'fotorama/fotorama.png' %>"). Add .erb extension and save.
In "app/assets/stylesheets/application.css" I add * require bower_components_manifest.
One of the other solutions, use gem "bower-rails". But I don't like it, because in some plugins in bower I need override some "main" files, and gem "bower-rails" can't do this, npm "main-bower-files" can. And I like to save my workflow for everything what I have done before start include my code to rails, gulp, bower.
I am very new to magento. I am really confused how to load my own CSS files into magento. From some internet help, I came to know that, we have to save these CSS files at some location similar to
var/www/company_name/skin/frontend/default/magento_new_theme/css/folder
I also read that during installation of magento, we create all these folders or they are created automatically. (Please correct me, if wrong).
The thing is , I have no magento installed. I am accessing the magento system from website of my company. And I really want some help regarding, where, I have to go to get this var folder?
Note : It is magento but not magento go.
For using css from current theme you can use the following
<link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('css/newstyle.css') >" media="all" />
To add your own CSS files, navigate to your local xml file. It will be at app/design/frontend/package/theme/layout/local.xml
If it does not exist, make a copy from the default folder into the same location in your theme's folders. Open it up and inside the section <reference name="head"> include the below
<!-- Custom CSS -->
<action method="addItem"><type>skin_css</type><name>css/Custom_file1.css</name><params/></action>
<action method="addItem"><type>skin_css</type><name>css/Custom_file2.css</name><params/></action>
Provided these CSS files exist in your skin/frontend/package/theme/css folder then they will be added to the document's head.
use this:
<?php
$this->getSkinUrl('css/name.css');
?>
If you have using default skin package and skin template magento_new_theme then,then you can use
Mage::getSkinUrl('css/folder'); //for folder
Css file
Mage::getSkinUrl('css/folder/yourcssfile.css');
Assuming your Magento installation is at the root URI of your website, the path for CSS is "/skin/frontend/package/theme/css" and for images "/skin/frontend/package/theme/images", typically.
The 'package' and 'theme' names will be set in your Magento admin. The default package is 'base' and the theme is 'default', so that path would be "/skin/frontend/base/default/".
You will need to ask your Magento admin what the package and theme names are.