简体   繁体   中英

CSS file not linking on changed Directories fully on Select/Option tab. HTTP-SERVER

Please note I am running this all from my local pc. Simply by opening html file. I am trying to organize my HTML documents better. Mainly only have one folder with assets where all the.js.css scripts etc are held. Is this a good idea or should I copy the same asset folder as well in sub folders where other html files would use this? Mainly I have a hierarchy like Top Folder -> {Assets, En, OtherLanguagesWillFollow} -> Under En ->{UserProfile, Folder1, Folder2 etc}

In the UserProfile Index.html I want to use the same css files from assets folder, which are in the top folder. Hence I have tried the following path:

  1. ../../assets/css/nameOfCssfile.css
  2. /assets/css/nameOfCssfile.css (when tried to run a http-server with node.js)
  3. Added a base folder and then linked it as assets/css/nameOfCssfile.css or./assets/css/nameOfCssfile.css

All of them gave me the same issue with the style of the page, some parts didn't work anymore, while most of the page looked like it has picked up the files, but some issues arose, mostly with code part like these. The issue is that the DDL is not showing any values any more.

 <div class="col-md-4 col-sm-4">
  <div class="form-group">
    <select class="form-control selectpicker"
     name="menu_type[]">
         <option value="">Select Country</option>
         <option value="1">Latvia</option>
         <option value="2">Estonia</option>
         <option value="3">Add New Country ...</option>
    </select>
  </div>
</div>

Once I copy paste the Assets class in the same folder as the html files this starts to work, without changing any of the path mentioned previously, meaning, while all files are still linked to the asset folder in the upper levels, it starts to work once it is copied in the same folder.

I tried to run this as well with http-server from node.js. Though I am not fully clear how this is working either, because I wanted to change all with /assets, so that I could link the folder from the upper folder.

  1. I run the http-server and could start it from firefox.
  2. Once I started the http-server option from other folder (navigating to it) it started to act weird. It somehow mixed these two folder, taking some code from the first option and some from the other, this was seen in the styling on the html.

Should this be actually run as:

  1. Navigate to the folder from cmd/node.js

  2. start the local host as http-server.

  3. use one or the other link to connect to the site I am creating as.

     C:\Users\raiti\Desktop\Folder of Everything\Code\ResponsiveSite>http-server Starting up http-server, serving./ Available on: http://192.168.1.103:8080 http://127.0.0.1:8080

How can I solve these two issues

  1. Getting a stable http-server
  2. best to organize the css/js files linkage to the html file?

I still don't understand why the code was showing up the css changes once I put the asset class in the folder of html file. After tidying up some code the issue wanished and not sure why, because the links didn't change. This is solved then.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM