Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Help styling a grid row

Explorer ,
May 14, 2019 May 14, 2019

Copy link to clipboard

Copied

I'm trying to style my bootstrap layout with a custom css file. I followed a youtube video on how to add grid rows with columns.

Below is my basic layout that I'm trying to style. I thought I was making some progress until I tried to add an image as a background in my header. It shows up in the header and the footer. Is that because they both have a class that says "col-sm-12" Do I need to change the name on a class? And what about the fact that I have a lot of div that says class=row? The video looked the same as my html except for being a fluid container.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Untitled Document</title>
    <!-- Bootstrap -->
<link href="css/bootstrap-4.3.1.css" rel="stylesheet">

  </head>
  <body>
   <!-- body code goes here -->
    <div class="container">
   <header class="row">
     <div class="col-sm-12">Content goes here</div>
      </header>
   <div class="row">
     <nav class="col-sm-3">Content goes here</nav>
    <main class="col-sm-9">Content goes here</main>
   </div>
   <footer class="row">
    <div class="col-sm-12">Content goes here</div>
   </footer>
    </div>
  <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="js/jquery-3.3.1.min.js"></script>

<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/popper.min.js"></script>
  <script src="js/bootstrap-4.3.1.js"></script>
  </body>
</html>

Views

3.4K
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 14, 2019 May 14, 2019

Copy link to clipboard

Copied

Try this:

<!doctype html>

<html lang="en">

<head>

<meta charset="utf-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Untitled Document</title>

<link href="css/bootstrap-4.3.1.css" rel="stylesheet">

<!--custom styles-->

<style>

header {

background: #000 url(https://placeimg.com/1200/200/nature) no-repeat center center;

background-size: cover;

min-height: 200px;

color: white;

}

nav { background-color: antiquewhite; }

main { background-color: beige; }

footer { background-color: tan; }

</style>

</head>

<body class="container">

<header class="row">

<div class="col">

<h1>My Awesome Website Header</h1>

<h2>Some Pithy Slogan....</h2></div>

</header>

<div class="row">

<nav class="col-sm-3">

Navigation goes here...

</nav>

<main class="col-sm-9">

<article>

<h3>Heading 3</h3>

<p>Main article content goes here. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptatem modi, reiciendis nulla excepturi nihil! Libero vitae rem illo deleniti quas amet quibusdam, voluptatem ipsum distinctio asperiores adipisci non alias sint.</p>

</article>

</main>

</div>

<footer class="row">

<div class="col">Footer goes here</div>

</footer>

<script src="js/jquery-3.3.1.min.js"></script>

<script src="js/popper.min.js"></script>

<script src="js/bootstrap-4.3.1.js"></script>

</body>

</html>

Nancy O'Shea— Product User, Community Expert & Moderator

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 14, 2019 May 14, 2019

Copy link to clipboard

Copied

I see in that file that it was styled inline. Is that a better way to add your own custom CSS? I am getting so frustrated because I can't seem to get the selector to select the area I want to change and then half the time I can't even get the selector to work. I tried changing some of my classes so they don't all say the same size col but now they all keep saying .container.row. I don't understand why I can't select just the header and make a change to that area only.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 14, 2019 May 14, 2019

Copy link to clipboard

Copied

There are 3 types of CSS code.

  • External -- a separate stylesheet to which all HTML documents are linked.
  • Embedded -- inside <style> tags inside the document <head> tag and below the external CSS.  Takes priority over external stylesheets.
  • Inline -  inside the HTML markup.  <p style="color: red">This paragraph is red</p>  Takes priority over embedded and external stylesheets.  Mainly used for HTML e-mails only.

When I'm developing a prototype in DW, I embed  my custom CSS inside the <head> tag.  Later, when I move into production,  I transfer embedded code to my custom external styesheet.   Important!  DO NOT EVER edit Bootstrap CSS or JS code.  If you break it, you won't be able to recover.  It's  too complex.  Always use a separate custom stylesheet instead.

Nancy O'Shea— Product User, Community Expert & Moderator

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 14, 2019 May 14, 2019

Copy link to clipboard

Copied

Open document in Split view.  I like code on the left and design/live on the right.

Click on the <header> in code side.  Press Ctrl+E to bring up the Quick Edit Panel.  You should now see all the relevant styles for the  <header>  selector.

Nancy O'Shea— Product User, Community Expert & Moderator

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 14, 2019 May 14, 2019

Copy link to clipboard

Copied

When I do that it says "no quick edit available for current cursor position.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 15, 2019 May 15, 2019

Copy link to clipboard

Copied

I have been so consumed with trying to create my website. I go to bed thinking about what I need to try next in order to get something to work and I think a lightbulb finally went on this morning and made me realize what my problem has been.

I'm feeling so stupid but it seems as though the reason I was having so much trouble trying to add custom css to the file was because I was never hitting enter when I'd select a selector. I just managed to do a lot of styling and it all came out the way I wanted it to.

I have to go out this morning so I can't work on it any more right now and I'm hoping when I get back to working on it, everything keeps working.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 15, 2019 May 15, 2019

Copy link to clipboard

Copied

sheryltoo  wrote

I'm feeling so stupid

Welcome to the club!

Wappler, the only real Dreamweaver alternative.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 15, 2019 May 15, 2019

Copy link to clipboard

Copied

sheryltoo  wrote

I'm feeling so stupid but it seems as though the reason I was having so much trouble trying to add custom css to the file was because I was never hitting enter when I'd select a selector. I just managed to do a lot of styling and it all came out the way I wanted it to.

That's as a direct result of taking short-cuts and not learning some basic programming. Unfortunately it happens far too frequently when skilled jobs are opened up to amatuers, who have no desire to learn anything correctly. Clicking buttons is a flawed 'hit and hope' approach.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 15, 2019 May 15, 2019

Copy link to clipboard

Copied

I've been trying to learn this new version but I'm old school where I learn best when I have a book in front of me and can follow along with the instructions. That's how I learned C6. I don't have any books yet for this version and most of the tutorials I've tried to watch don't always tell you the things that are probably obvious. Either that or I some how skipped over them.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 15, 2019 May 15, 2019

Copy link to clipboard

Copied

sheryltoo  wrote

I've been trying to learn this new version but I'm old school where I learn best when I have a book in front of me and can follow along with the instructions. That's how I learned C6. I don't have any books yet for this version and most of the tutorials I've tried to watch don't always tell you the things that are probably obvious. Either that or I some how skipped over them.

That's where you are going completely wrong, in my opinion. You don't learn DW you learn html/css and then it doesn't really matter what editor you choose to use. A basic knowledge of html and css will allow you to code your way out of most situations and negate the reliance on a specific editor to do it for you.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 15, 2019 May 15, 2019

Copy link to clipboard

Copied

I actually thought I had learned quite a bit about html and css but it looks as if I have to learn it all over again. When I originally set up my website, I had multiple layers and used id as the selector, not class. The only instructions I've seen so far for bootstrap use class.

It seems to be confusing me.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 15, 2019 May 15, 2019

Copy link to clipboard

Copied

sheryltoo  wrote

I actually thought I had learned quite a bit about html and css but it looks as if I have to learn it all over again. When I originally set up my website, I had multiple layers and used id as the selector, not class. The only instructions I've seen so far for bootstrap use class.

It seems to be confusing me.

General rule of thumb is to only use 1 unique id per page. You can use the same class as many time as you like.

The reason is javascript selects a specific id

const name = document.getElementById('name');

if you have have 2 elements with the same id it will only ever select the first id and ignore any id after the first one.

<div id="name">Minnie</div>

<div id="name">Donald</div>

You will only be able to change the html of the first instance of the id:

name.innerHTML = 'Pluto';

However with classes you can select ALL the elements which have the same class

const name = document.getElementsByClassName('name');

<div class="name">Minnie</div>

<div class="name">Donald</div>

You can change the html of all the elements which have a class

name[0].innerHTML = 'Pluto';

name[1].innerHTML = 'Mickey';

Least of all a page won't validate if there is more than one unique id per page

So in conclusion the page will be invalid if you use multiple ids of the same name per page and it will confuse javascript if you are using it and you probably will at some stage.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 15, 2019 May 15, 2019

Copy link to clipboard

Copied

When I used ID, they all had different names. I never really did much with the class selector.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 15, 2019 May 15, 2019

Copy link to clipboard

Copied

sheryltoo  wrote

When I used ID, they all had different names. I never really did much with the class selector.

That's ok then but I dont think its used in much main-stream development these days as its better practice to use:

<nav>

<a class="link">Link 1</a>

<a class="link">Link 2</a>

<a class="link">Link 3</a>

<a class="link">Link 4</a>

</nav>

Instead of giving your anchor tags each an individual id:

<nav>

<a id="link_1">Link 1</a>

<a id="link_2">Link 2</a>

<a id="link_3">Link 3</a>

<a id="link_4">Link 4</a>

</nav>

infact both examples above are terrible practice, one of which is used by Bootstrap, but you get my point.

Bootstrap use this kind of rubbish code:

<div class="navbar-nav">

<a class="nav-item nav-link">Link 1</a>

</div>

This is more streamlined:

<nav>

<a>Link 1</a>

<a>Link 2</a>

<a>Link 3</a>

<a>Link 4</a>

</nav>

nav a {

style your anchor tags

}


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 15, 2019 May 15, 2019

Copy link to clipboard

Copied

Thanks. And speaking of the nav tabs, I've been trying to work with nav-pills. It sounds like I shouldn't. If I style anchor tags, is that done in the same manner as before Bootstrap?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 15, 2019 May 15, 2019

Copy link to clipboard

Copied

sheryltoo  wrote

Thanks. And speaking of the nav tabs, I've been trying to work with nav-pills. It sounds like I shouldn't. If I style anchor tags, is that done in the same manner as before Bootstrap?

If you dont use Bootstrap you can style your anchor tags how you did before. Bootstrap isn't mandatory it's just part of DW. All the styling is done for you and you just add the Bootstrap css classes except you will most probably change 90% of the css properties to suit the colors, spacing etc you require.

Its a question of whether you learn Bootstrap and run with it or learn some simple html/css and create your own responsive contructions. This largely depends on where you are personally going. If you're considering a career in web-development and are giong to be looking for employment then you MUST learn Bootstrap. However its more critical to learn html/css, only then can you judge if Bootstrap is a good fit for you or not.

I could use Bootstrap tomorrow but I choose not to because once you know html/css its far simpler to create your own responsive layouts in a more oganised way and with a lot less code BUT Im in a fortunate position of not looking for employment, so I can do what I like.

If you're not considering a career in web-development then it's not going to be worth the time learning html/css, most in that category just muddle through with Bootstrap adding classes here and there to form some kind of creation or they would use something like Webflow or Square Space.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 15, 2019 May 15, 2019

Copy link to clipboard

Copied

Thanks for that information. I'm not looking for a job or career. My website is just for personal use and  one of reason I started it was because I love to draw images in a paint program and then use them as designs on a web page. I used to write tutorials on how I drew my designs and wanted a place to store them so I wouldn't forget what I did. Plus I would share them with other people who enjoyed making their own graphics.

I hadn't been keeping up with the latest way to code websites until my brother pointed out the fact my site didn't appear correctly on his computer. Now I know that it's because my site wasn't built using a responsive design. I thought I had to use Bootstrap in order to make everything work correctly so thanks for letting me know that's not the case.

Maybe I'll try working on it without using Bootstrap.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 15, 2019 May 15, 2019

Copy link to clipboard

Copied

sheryltoo  wrote

I thought I had to use Bootstrap in order to make everything work correctly so thanks for letting me know that's not the case.

I think that is part of the problem. Many think just because Bootstrap is in DW its the only way to produce a responsive construction.

Do a youtube search and look for responsive tutorials that dont use Bootstrap. They may be simpler if you are familar will some html/css and used to styling your own elements. Whilst Bootstrap is popular, mainly for teamwork environments, not all developers, especailly good individual developers like it. Very often developers are 'forced' to use a workflow they would much rather not given the choice but sometimes in the real world money speaks louder than words and if all the team is singing from the same hymn they are interchangable.

If you're an individual you can be a bit more discerning.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 15, 2019 May 15, 2019

Copy link to clipboard

Copied

Thanks again for that info. I did do a search for a youtube video after my last reply and found one that I think is going to be very helpful. It's done in Dreamweaver and has exercise files. I'm working on it now. I'm hoping this will seem more familiar to me and easier.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 15, 2019 May 15, 2019

Copy link to clipboard

Copied

sheryltoo  wrote

Thanks again for that info. I did do a search for a youtube video after my last reply and found one that I think is going to be very helpful. It's done in Dreamweaver and has exercise files. I'm working on it now. I'm hoping this will seem more familiar to me and easier.

Let us know how you get on. If you get stuck post back and ask some questions. I'm sure the regulars in the forum can provide some guidance, whether you eventually decide to use Bootstrap or build using your own workflow.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 17, 2019 May 17, 2019

Copy link to clipboard

Copied

OK. I'm stuck. I decided to buy an O'Reilly book called "Learning Web Design". I've been learning a lot and grasping some of it. Right now I'm trying to learn how to create a website using the Flex attribute. In the book it shows how to set up a simple page that has a heading, an article, 2 aside, and a footer.

I have the html set and now I'm trying to create the Css file. The instructions show I need to have flex as the display in my main section but when I click on display under layout, there's no option for Flex. How do I get the flex option or do I even want to try learning this way of setting up my page?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 17, 2019 May 17, 2019

Copy link to clipboard

Copied

sheryltoo  wrote

OK. I'm stuck. I decided to buy an O'Reilly book called "Learning Web Design". I've been learning a lot and grasping some of it. Right now I'm trying to learn how to create a website using the Flex attribute. In the book it shows how to set up a simple page that has a heading, an article, 2 aside, and a footer.

I have the html set and now I'm trying to create the Css file. The instructions show I need to have flex as the display in my main section but when I click on display under layout, there's no option for Flex. How do I get the flex option or do I even want to try learning this way of setting up my page?

Probably your version of Dreamweaver doesnt have the css flex specifications available as default. What version are you using?

This doesn't mean you can't use flex it just means you will have to manually declare it in your css selectors, like the example below:

Lets suppose I have a section with the class of main-section:

<section class="main-section">

</section>

My css selector would look as below:

.main-section {

display: flex;

}

Yes, flex is the way to go, all modern responsive websites are now using that technique, along with the more advanced 'grid' but that needs fall backs to work in IE.

flex is easy to use:

html:

<div class="main-section">

<main class="main-content">

Main content goes here

</main>

<!-- end main-content -->

<aside class="sidebar">

Sidebar content goes here

</aside>

<!-- end sidebar -->

</div>

<!-- end main-section -->

css:

.main-section {

display: flex; /*this will position the 2 divs in main-section side by side*/

flex-wrap: wrap; /*this will allow for the 2 divs to wrap to their own row on smaller screens*/

width: 80%; /*this sets width of main-section*/

margin: 0 auto; /*this will horizontally center the main-section*/

}

/*set width of child divs */

.main-content {

width: 70%;

}

.sidebar {

width: 30%;

}

/* use a css media query to re-purpose the divs inside main-section at smaller screens width*/

/* you may want to allocate a different ratio of percentage width on a smaller screen */

@media screen and (max-width: 768px) {

.main-content {

width: 60%;

}

.sidebar {

width: 40%;

}

}

/* 100% width - 1 column - ideal for smartphone, can be used on tablet as well if needed - use 768px for the media query for tablet devices*/

@media screen and (max-width: 480px) {

.main-content {

width: 100%;

}

.sidebar {

width: 100%;

}

}

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 17, 2019 May 17, 2019

Copy link to clipboard

Copied

I must have the latest version of Dreamweaver because I just downloaded it last week and signed up for the monthly payments. Is Flex like a link some place?

And since I wasn't haven't much success with my flex document, I decided to go on in my book so now I'm up to CSS grid layouts. I also just read that no version of IE supports the current grid standard so I can see why maybe I better try and figure out flex.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 17, 2019 May 17, 2019

Copy link to clipboard

Copied

sheryltoo  wrote

I must have the latest version of Dreamweaver because I just downloaded it last week and signed up for the monthly payments. Is Flex like a link some place?

And since I wasn't haven't much success with my flex document, I decided to go on in my book so now I'm up to CSS grid layouts. I also just read that no version of IE supports the current grid standard so I can see why maybe I better try and figure out flex.

I don't use Dreamweaver myself but I'm sure the latest version must have all the flex css specifications available by now, maybe one of the other regulars can confirm.

No flex is not a link it's just a set of standard css attributes.

Don't use 'grid' at the moment would be my advice, its probably another 2 years from being 'stable' without fallbacks. Whilst all modern browsers support it IE doesn't so in that respect you have to either igonore those using IE (I dont know what percentage use it but it must be small and getting smaller) or just stick to flex as tried and tested.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines