What is the difference if I store the main.css file in /webroot/myapp/css or /webroot/assets/css?
This one is working...
<link rel="stylesheet" href="/assets/css/main.css" type="text/css" />
This one does not...
<link rel="stylesheet" href="/myapp/css/main.css" type="text/css" />
Why?
Load the URL helper and then add to your href like so:
<link rel="stylesheet" href="<?php echo base_url() ?>/assets/css/main.css" type="text/css" />
Related
I've spent the last 7 hours trying to load my assets folder to my view file but for some reason it didn't work ! i read the docs , stackoverflow posts & tried everything but nothing seems to be working.
here's my folder structures:
htdocs
CRM
app-assets
css
pages
dashboard-ecommerce.css
bootstrap.css
bootstrap-extended.css
vendors
css
vendors.min.css
charts
apexcharts.css
extensions
swiper.min.css
Applications
controllers
dashboard.php
views
dashboard.php
assets
(+ the rest of the files with .htaccess included)
Now here's the dashboard's header part:
<!-- BEGIN: Vendor CSS-->
<link rel="stylesheet" type="text/css" href="app-assets/vendors/css/vendors.min.css">
<link rel="stylesheet" type="text/css" href="app-assets/vendors/css/charts/apexcharts.css">
<link rel="stylesheet" type="text/css" href="app-assets/vendors/css/extensions/swiper.min.css">
<!-- END: Vendor CSS-->
<!-- BEGIN: Theme CSS-->
<link rel="stylesheet" type="text/css" href="app-assets/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="app-assets/css/bootstrap-extended.css">
<!-- BEGIN: Page CSS-->
<link rel="stylesheet" type="text/css" href="app-assets/css/pages/dashboard-ecommerce.css">
<!-- END: Page CSS-->
Note that i did change the config file to
$config['base_url'] = 'http://localhost/CRM'
but nothing worked.
Here is simple solution for this problem
<link rel="stylesheet" type="text/css" href="<?=base_url('app-assets/vendors/css/vendors.min.css')?>">
<link rel="stylesheet" type="text/css" href="<?=base_url('app-assets/vendors/css/charts/apexcharts.css')?>">
<link rel="stylesheet" type="text/css" href="<?=base_url('app-assets/vendors/css/extensions/swiper.min.css')?>">
base_url will proper base URL to the asset path.
In my root, I have index.php which references css files like this:
<link rel="stylesheet" href="css/style.css" type="text/css" />
<link rel="stylesheet" href="css/custom.css" type="text/css" />
I have a rewrite rule that makes my path example.com/products/.....
RewriteRule ^products/([0-9a-zA-Z-]+)$ product-detail.php?slug=$1 [NC,L]
The issue I have is that the css links are now broken on the products pages because the reference to the css files is incorrect as it should change to:
<link rel="stylesheet" href="../css/style.css" type="text/css" />
<link rel="stylesheet" href="../css/custom.css" type="text/css" />
I would like to have a header.php file where I can just make changes once if I need to add or remove css references but now I have to have 2 make changes twice. Is there a way around this?
you can start the include with the root path
<link rel="stylesheet" href="/css/style.css" type="text/css" />
I solved this by adding this to the head:
<base href="//localhost:8888/mysite/" />
Currently have a site built using SASS, however due to the fact it was not compiling we decided to edit the cw-styles CSS in our DEV environment and upload this to the FTP instead.
This is how we are linking the css in the Head section currently:
<link href="http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<link href="/<?php echo SITE_FOLDER; ?>/css/all.css" rel="stylesheet" type="text/css" />
<link href="/common/js/image/swipe.css" rel="stylesheet" type="text/css" />
<link href="/mse/css/cw-styles.css" rel="stylesheet" type="text/css" />
However on uploading this, in the Head section the link to the stylesheet on the Live site has broken, giving us a link that looks like this:
<link href="/mse,_uploads,_all.crush.css,q23409834296+common,_js,_image,_swipe.css+mse,_css,_cw-styles.css+common,_js,_lightbox,_lightbox.css+common,_js,_image,_swipe.css.pagespeed.cc.0Keg4MRi-i.css" rel="stylesheet" type="text/css"/>
Anyone experienced this, or clues as to why this is happening?
So, I've had a look around, become somewhat overwhelmed by the variety of different answers I've come across and would like a hand.
My included PHP header CSS files currently look like this:
<meta name="viewport" content="initial-scale=1.0">
<link href="CSS/header.css" type="text/css" rel="stylesheet" />
<link href="CSS/ufc-blog.css" type="text/css" rel="stylesheet" />
<link href="CSS/ufc205.css" type="text/css" rel="stylesheet" />
<link href="CSS/cerrone-lawler.css" type="text/css" rel="stylesheet" />
How can I specify the path and then enter a variable from the page with the included header that set the stylesheet to display the CSS specifically for that page?
I am trying to use the PHP Framework CodeIgniter for a PHP project. I never used it before. According to its documentation I activated the helper URL and included the css link as shown below:
$autoload['helper'] = array('url');
<link rel="stylesheet" type="text/css"
href="<?php echo base_url();?>public/css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css"
href="<?php echo base_url();?>public/css/style.css"/>
Unfortunately the page is not able to load the css. Obviously if I put the compiled CSS link the page is able to load it.
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
Base_url() does not add a trailing slash. You need a forward slash in between the PHP code and public in the link href.
Say your base url is /htdocs/website/, the way you currently have it set up would print out /htdocs/websitepublic/css/style.css.
Here is the fixed code:
<link rel="stylesheet" type="text/css" href="<?php echo base_url();>/public/css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo base_url();>/public/css/style.css"/>