webdevRefinery Forum: How to make this in html - webdevRefinery Forum

Jump to content

  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Rate Topic: -----

User is offline Sole_Wolf 

  • Group: Members
  • Posts: 307
  • Joined: 24-March 10
  • Expertise:HTML,PHP,Java,SQL

Posted 10 March 2012 - 03:42 AM (#1)

How to make this in html


Look at image
I want to make an HP bar using HTML and CSS but I don't know how I would do it. The best of my ability is practically [------------] as a bar instead of an actual rounded corner rectangle.

I am trying to make it look something like these but I don't know where to start.
Posted Image
--Sole_Wolf
0


User is offline Cyril 

  • Group: Members
  • Posts: 2545
  • Joined: 03-August 10
  • Expertise:HTML,CSS,PHP,Javascript,Graphics

Posted 10 March 2012 - 04:01 AM (#2)

Div in a div, inner div with a width in %, and some styling. Border-radius for the corners.

website :: github :: twitter :: dribbble :: forrst
html, css, php, javascript, graphics
0


User is offline gibbonweb 

  • 兄ヨハネス
  • Group: Members
  • Posts: 2063
  • Joined: 23-June 10
  • LocationMunich(DE)
  • Expertise:HTML,CSS,PHP,Javascript,Python,SQL,Graphics

Posted 10 March 2012 - 10:00 AM (#3)

<div class="wrapper">
    <div class="bar" style="width: 65%">65/100 HP</div>
</div>


start with a simple style like:

.bar {
    background: red;
    height: 1em;
    overflow: visible;
    color: white
}


Ah what the heck, check this out: http://tinkerbin.com/3HRHWOYp

further styling can of course be done with a background-image for
.bar
, rounded corners, et cetera!
0


User is offline Nand 

  • Group: Members
  • Posts: 36
  • Joined: 24-February 12
  • Expertise:PHP,SQL

Posted 10 March 2012 - 10:57 AM (#4)

Or you could just use two images.

<img src="white.png" style="height:15px;width: 20px" />
<img src="black.png" style="height:15px;width: 80px" />


You can even wrap a div element around it if you want to specify percentages.
0


User is offline Hyde 

  • Group: Members
  • Posts: 1580
  • Joined: 08-March 10

Posted 10 March 2012 - 11:22 AM (#5)

View PostNand, on 10 March 2012 - 10:57 AM, said:

Or you could just use two images.

<img src="white.png" style="height:15px;width: 20px" />
<img src="black.png" style="height:15px;width: 80px" />


You can even wrap a div element around it if you want to specify percentages.

Gah! Inline CSS! Run for your life!
Hyde | HTML & CSS | PHP & SQL | Objective-C | Java | Basic JavaScript
1


User is offline Cyril 

  • Group: Members
  • Posts: 2545
  • Joined: 03-August 10
  • Expertise:HTML,CSS,PHP,Javascript,Graphics

Posted 10 March 2012 - 11:23 AM (#6)

Slightly more styled version of Gibb's: http://tinkerbin.com/IMnG73fR
@Nand, using images isn't great to start with, this is even worth. Working with that is going to be messy and if you're making something integrated into a backend, you'll have to have twice the code needed to display.

Edit: @Hyde, inline CSS is fine for things like this. Normal styling should be in CSS, but things like this are fine. (that is, inline width, in percentages for example, to serve as a health bar)

website :: github :: twitter :: dribbble :: forrst
html, css, php, javascript, graphics
0


User is offline gibbonweb 

  • 兄ヨハネス
  • Group: Members
  • Posts: 2063
  • Joined: 23-June 10
  • LocationMunich(DE)
  • Expertise:HTML,CSS,PHP,Javascript,Python,SQL,Graphics

Posted 10 March 2012 - 12:25 PM (#7)

View PostHyde, on 10 March 2012 - 11:22 AM, said:

Gah! Inline CSS! Run for your life!

so.... YOU would so something like
.width1 {width: 1%; }
.width2 {width: 2%; }
.width3 {width: 3%; }
.width4 {width: 4%; }
.width5 {width: 5%; }
.width6 {width: 6%; }

until 100?

:rolleyes:
0


User is offline iCyan 

  • Group: Members
  • Posts: 205
  • Joined: 15-May 11
  • Expertise:HTML,CSS,Graphics,Flash

Posted 10 March 2012 - 12:50 PM (#8)

Isn't wdR awesome? Very helpfull :)
You should also make it so that the bar changes colour to yellow and red when at lower healths. Add that extra touch of awesome ;)
iCyan Allias
0


User is offline Cyril 

  • Group: Members
  • Posts: 2545
  • Joined: 03-August 10
  • Expertise:HTML,CSS,PHP,Javascript,Graphics

Posted 10 March 2012 - 12:54 PM (#9)

View PostiCyan, on 10 March 2012 - 12:50 PM, said:

Isn't wdR awesome? Very helpfull :)
You should also make it so that the bar changes colour to yellow and red when at lower healths. Add that extra touch of awesome ;)


http://tinkerbin.com/8pyvjFDb

website :: github :: twitter :: dribbble :: forrst
html, css, php, javascript, graphics
0


User is online TheEmpty 

  • I say words in sequences.
  • Group: Members
  • Posts: 5169
  • Joined: 02-October 10
  • Expertise:HTML,CSS,PHP,Java,Javascript,Python,Ruby on Rails,SQL

Posted 10 March 2012 - 12:55 PM (#10)

View Postgibbonweb, on 10 March 2012 - 12:25 PM, said:

so.... YOU would so something like
.width1 {width: 1%; }
.width2 {width: 2%; }
.width3 {width: 3%; }
.width4 {width: 4%; }
.width5 {width: 5%; }
.width6 {width: 6%; }

until 100?

:rolleyes:


$('#bar1').width('5%');


View PostCyril, on 10 March 2012 - 12:54 PM, said:


Fixed: http://tinkerbin.com/Kydq51s9
Reserved.
0


User is offline Cyril 

  • Group: Members
  • Posts: 2545
  • Joined: 03-August 10
  • Expertise:HTML,CSS,PHP,Javascript,Graphics

Posted 10 March 2012 - 12:58 PM (#11)

View PostThatRailsGuy, on 10 March 2012 - 12:55 PM, said:



Eh? You didn't change anything.

website :: github :: twitter :: dribbble :: forrst
html, css, php, javascript, graphics
0


User is online TheEmpty 

  • I say words in sequences.
  • Group: Members
  • Posts: 5169
  • Joined: 02-October 10
  • Expertise:HTML,CSS,PHP,Java,Javascript,Python,Ruby on Rails,SQL

Posted 10 March 2012 - 01:31 PM (#12)

View PostCyril, on 10 March 2012 - 12:58 PM, said:

Eh? You didn't change anything.

text @ 3rd
Reserved.
0


User is offline Cyril 

  • Group: Members
  • Posts: 2545
  • Joined: 03-August 10
  • Expertise:HTML,CSS,PHP,Javascript,Graphics

Posted 10 March 2012 - 01:35 PM (#13)

View PostThatRailsGuy, on 10 March 2012 - 01:31 PM, said:

text @ 3rd


Yes...? It's correct?

website :: github :: twitter :: dribbble :: forrst
html, css, php, javascript, graphics
0


User is online TheEmpty 

  • I say words in sequences.
  • Group: Members
  • Posts: 5169
  • Joined: 02-October 10
  • Expertise:HTML,CSS,PHP,Java,Javascript,Python,Ruby on Rails,SQL

Posted 10 March 2012 - 02:32 PM (#14)

View PostCyril, on 10 March 2012 - 01:35 PM, said:

Yes...? It's correct?

It wasn't.
Reserved.
0


User is offline Cyril 

  • Group: Members
  • Posts: 2545
  • Joined: 03-August 10
  • Expertise:HTML,CSS,PHP,Javascript,Graphics

Posted 10 March 2012 - 03:07 PM (#15)

View PostThatRailsGuy, on 10 March 2012 - 02:32 PM, said:

It wasn't.


Well considering the one you quoted is right... :/

website :: github :: twitter :: dribbble :: forrst
html, css, php, javascript, graphics
0


User is offline gibbonweb 

  • 兄ヨハネス
  • Group: Members
  • Posts: 2063
  • Joined: 23-June 10
  • LocationMunich(DE)
  • Expertise:HTML,CSS,PHP,Javascript,Python,SQL,Graphics

Posted 10 March 2012 - 05:21 PM (#16)

View PostThatRailsGuy, on 10 March 2012 - 12:55 PM, said:

$('#bar1').width('5%');


so just to avoid one line of (justifiable) inline css you'd include jQuery?


HOW EFFICIENT :P
1


User is offline Cyril 

  • Group: Members
  • Posts: 2545
  • Joined: 03-August 10
  • Expertise:HTML,CSS,PHP,Javascript,Graphics

Posted 10 March 2012 - 05:43 PM (#17)

View Postgibbonweb, on 10 March 2012 - 05:21 PM, said:

so just to avoid one line of (justifiable) inline css you'd include jQuery?


HOW EFFICIENT :P


Mind you, jQuery would translate that to inline CSS anyway.

website :: github :: twitter :: dribbble :: forrst
html, css, php, javascript, graphics
0


User is online TheEmpty 

  • I say words in sequences.
  • Group: Members
  • Posts: 5169
  • Joined: 02-October 10
  • Expertise:HTML,CSS,PHP,Java,Javascript,Python,Ruby on Rails,SQL

Posted 10 March 2012 - 06:50 PM (#18)

View Postgibbonweb, on 10 March 2012 - 05:21 PM, said:

so just to avoid one line of (justifiable) inline css you'd include jQuery?


HOW EFFICIENT :P

I've never worked with an app that didn't have jQuery in it. It would be just as easy to do that in basic JS too.
Reserved.
0


User is offline Renegade 

  • 418 I'm a teapot
  • Group: Members
  • Posts: 748
  • Joined: 08-March 10
  • Expertise:HTML,CSS,PHP,Javascript,Node.js,SQL,Graphics

Posted 10 March 2012 - 08:17 PM (#19)

Even more stylized version: http://tinkerbin.com/6eZsZfe6

Warning: It is extremely painful watching that moving progress bar.
http://adriancooney.ieGithubTwitterDribbbleForrst
We all die. The goal isn't to live forever. The goal is to create something that will.

Array(16).join({}-{}) + " Batman!";
0


User is online TheEmpty 

  • I say words in sequences.
  • Group: Members
  • Posts: 5169
  • Joined: 02-October 10
  • Expertise:HTML,CSS,PHP,Java,Javascript,Python,Ruby on Rails,SQL

Posted 10 March 2012 - 08:42 PM (#20)

Renegade, on my W7 Chrome the stripes don't line up on repeat, but nice lookin' :)
Reserved.
0


Share this topic:


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users


Enter your sign in name and password


Sign in options
  Or sign in with these services