Official Programmers Thread

  • Christian Chat is a moderated online Christian community allowing Christians around the world to fellowship with each other in real time chat via webcam, voice, and text, with the Christian Chat app. You can also start or participate in a Bible-based discussion here in the Christian Chat Forums, where members can also share with each other their own videos, pictures, or favorite Christian music.

    If you are a Christian and need encouragement and fellowship, we're here for you! If you are not a Christian but interested in knowing more about Jesus our Lord, you're also welcome! Want to know what the Bible says, and how you can apply it to your life? Join us!

    To make new Christian friends now around the world, click here to join Christian Chat.
W

wwjd_kilden

Guest
anyone here good at xhtml/ css?

I'm trying to make my text lines break

atm I've simply chosen notto set height/ width for my box (so it adapts to the text within it)

is there any other logic way of forcing the text to fit, within a set sized box? like some- auto scaling of the text? or would that just be complicated?
 
B

Belgian_Pilot

Guest
Astrid, for layout purposes, making the textbox fit around the text is a bad idea. If the text is changed by the user, the box changes, and the layout is messed up.

Make a <div> </div> (and give it a name), define in the css file the correct size of the div, and the text will stay inside.
 
W

wwjd_kilden

Guest
ah, I tried that first, but somehow I ended up with everything floating so much that the boxes would hop around like crazy when I resized the window :p
I think it's better now though. (And now I wish I had saved an older version to see what on earth I did earlier :p)
 
B

Belgian_Pilot

Guest
Floating problems can be solved adapting certain values. Here's an example

Now the css-file:

#top-information
{
height: 215px; <=====| height will never change (even if more text is added)
margin-left: auto; <=====| this will centre the div
margin-right: auto; <=====| even if the window is resized
margin-bottom: 0px;
margin-top: 10px;
color: #0c0cf1;
background-color: Olive ;
font-size: .85em;
position: relative; <=====| Are the values relative to other values?
width: 750px;
background-image: url(Images/image2826.png);
background-repeat: no-repeat
}
#menu
{
width: 750px;
height: auto; <=====| If more text is added, the div will adapt it's height
margin-left: auto;
margin-right: auto;
position: relative;
margin-bottom: 0px;
margin-top: 10px;
text-align: center;
background-color: Olive;
font-family: Verdana;
}
If you are working with multiple divs, or you need other floating effects, use float and clear tags.

Floatutorial: Tutorial 2 - Step 3
Floatutorial: Tutorial 3 - Step 4
 
W

wwjd_kilden

Guest
ooooh, that's how it's done. tnx :D

will have a look at it after breakfast
 
B

Belgian_Pilot

Guest
Enjoy your breakfast!

If you need any examples, I know some css.
 
W

wwjd_kilden

Guest
I think I can guarantee there'll be questions :p our assignments in one of the classes will be in or partially in xhtml and css :D
 
W

wwjd_kilden

Guest
hmm, seems like I have to change my other divs then, cause if I put in that menu as a sidebar and place it to the side, my floating divs disappear :p
 
B

Belgian_Pilot

Guest
I gotta go now, but post your css code + html code, and I'll have a look.
 
W

wwjd_kilden

Guest
<!--html-->
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="no" lang="no">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
Testside XHTML/CSS
</title>
<link rel="stylesheet" type="text/css" href="css2.css" media="screen" />
</head>


<body>
<h1> Heading </h1>

<!--<div id="venstreramma">-->

<div id="lframe">
test
<br/>
sideframes
</div>

<div id="rframe">
<p class="right">
testing floating frame to see if text stays within frames or ands up outside the box
</p>
</div>

<div id="boks">
<p class="large"> some text </p>

<img class="float" alt="solar flare" src ="flare.jpg"/>
<p class="bilde"> I'd like this to stay withing a given length.
so it fits under a image by itself if possible </p>
<!-- hvordan få denne på en makslengde så den passer til bildestr?-->
<p class="left">
left foating text here to test
</p>

<p>
everything is moving around if I make windows smaller :eek:
</p>

</div>

<div id="rammer">
<img class="test" alt="flare" src ="flare.jpg"/>
<img class="test" alt="giraffe" src ="gir.jpg"/>
<!-- annen type bildeskalering-->

</div>


<!-- COPYPASTE-->

<table cellspacing="0" class="table_ex">
<!-- Rad 1 -->
<tr>
<th>
Overskrift 1
</th>

<th>
Overskrift 2
</th>
</tr>
<!-- // SLUTT Rad 1 -->

<!-- Rad 2 -->
<tr>
<td>
Data 1
</td>

<td>
Data 2
</td>
</tr>
<!-- // SLUTT Rad 1 -->

<tr>
<td rowspan="2"> <!-- ett felt går over to rader-->
mer 1
</td>

<td>
mer 2
</td>
</tr>
<!-- // SLUTT Rad 2 -->
<tr>
<td>

mer mer
</td>
</tr>

</table>


<!--
Tabell med 2 horisontale celler slått sammen
-->



<table cellspacing="0" class="table_ex">
<!-- Rad 1 -->
<tr>
<th>
Overskrift 1
</th>


<th colspan="2"> <!--overskriften strekkes over to kolonner-->
Overskrift 2
</th>
</tr>
<!-- // SLUTT Rad 1 -->

<!-- Rad 2 -->
<tr>
<td>
Data 1
</td>

<td>
Data 2
</td>

<td>
Data 3
</td>
</tr>
<!-- // SLUTT Rad 2 -->
</table>

<p>
Tabell med to overskriftceller <br/>
slått sammen horisontalt (<b>colspan="2"</b>).
</p>



</div>

<div id="cc">
this thing is not working the way I want it to,
it should cover the whole left side :p
</div>
<!-- COPYPASTE-->

</body>
</html>



/*CSS*/

body
{
font-family: "Arial";
font-size: 100%;
}
h1
{
color: red;
font-family: "Courier New";
font-style: Italic;
font-weight: lighter;
text-align: center;
}


div#boks
{
margin-left: auto;
margin-right: auto;
margin-top: auto;
/*float: center;*/
background-color: blue;
text-align: center;
border: 1px solid #000000;
}

img
{
width: 50%;
height: 50%;
float: center;
}

p
{
color: black;
font-size: 12px;
font-family: Arial;
}

p.large
{
color: green;
font-size: 20px;
font-family: Impact;
}

p.bilde
{
margin: .2em;
font-size: 15px;
color: white;
font-weight: Lighter;
}

p.clear {
fl: left;
margin-left: 280px;
}

p.left { /* div.boks er satt til text align center, så må bruke denne for å venstrestille tekst i boksen*/
text-align: left;
font-size: 10px;
color: yellow;
}

p.right /* for å plassere teksten i forhold til rammen*/
{
width: 100px;
color: green;
margin-left: .5em;
margin-right: .5em;
}

div.rammer
{
float: left;
margin: .5em;
}

img.test /* undergruppe av bilder, disse er mindre enn standard*/
{width: 30%;
height: 45%;
margin: .5em;
}

img.float
{
float: center;
}

/*copypaste*/

/*plassering og linjestil */
table.table_ex {
clear: left;
float:center;
/*border-top: 1px solid #000; /*topplinje*/
/*border-right: 1px solid #000; /*høyre linjer*/
margin: 0em 1em 2em 1em; /* gir mellomrom ....topp høyre bunn venstre */
border-style:double; /*venstre og nede*/
}
/*rammer*/
table.table_ex th, table.table_ex td {
border-left: 1px solid #000; /* venstre linjer*/
border-bottom: 1px solid #000; /*nedre linjer*/
border-top: 1px solid #000;
border-right: 1px solid #000;
}

/*padding*/
table.table_ex th { /*header*/
background-color: #FF0000;
padding: .2em 1em; /* fyll ... bredde lengde */
}
/*align tekst*/
table.table_ex * {
text-align: center;
}

div#lframe
{
float:left;
width: 100px;
height: 200px;
padding: 10px;
margin-top: 1em; /*gjør at floaten inni diven ikke forkyves når det er tekst over diven*/
}

div#rframe
{
float:right;
width: 100px;
height: auto;
padding: 10px;
margin-top: 1em;
background-color: red;
margin-right: .5em;
}

div#venstreramma{ /* FAILS*/
margin: 0 auto 0 auto;
width: 200px;
height: 600px;
float: left;
padding: 5px;
background-color: #ababab;
border-top: 1px solid #000;
position: relative;
margin-left:auto;
margin-right: auto;
}


div#cc /* overlaps other divs*/
{
width: 200px;
height: auto;
margin-right: auto;
position: relative;
margin-bottom: 0px;
margin-top: 10px;
text-align: center;
background-color: Olive;
font-family: Verdana;
}
 
W

wwjd_kilden

Guest
so, basically I want

- a sidebar on the left
- the floating boxes to stay on the left | right side of the picture, without moving when I minimize the window (in other words, it should behave like a standard web page... if I make the window smaller, I can't see what's "oustside" it

(the pictures under the blue field can move all they want :p)
 
W

wwjd_kilden

Guest
duh... I had to give a set size for my blue box.... but if there are other soultions I'd love to see how they work


and I still can't figure out the sidebar (maybe I will in a bit :p)
 
B

Belgian_Pilot

Guest
Testing Astrid's code...


AAAAAHHHH my eyes!!!!!!!!!!!!!!!! Blue - red :p:p:p
 
B

Belgian_Pilot

Guest
<!--html-->
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="XHTML namespace" xml:lang="no" lang="no">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
Testside XHTML/CSS
</title>
<link rel="stylesheet" type="text/css" href="css2.css" media="screen" />
</head>

<body>
<div id="wrap">
<div id="cc">
this thing is not working the way I want it to,
it should cover the whole left side
</div>
<div id="right">
<h1> Heading </h1>
<!--<div id="venstreramma">-->
<div id="lframe">
test
<br/>
sideframes
</div>
<div id="rframe">
<p class="right">
testing floating frame to see if text stays within frames or ands up outside the box
</p>
</div>
<div id="boks">
<p class="large"> some text </p>
<img class="float" alt="solar flare" src ="flare.jpg"/>
<p class="bilde"> I'd like this to stay withing a given length.
so it fits under a image by itself if possible </p>
<!-- hvordan få denne på en makslengde så den passer til bildestr?-->
<p class="left">
left foating text here to test
</p>
<p>
everything is moving around if I make windows smaller
</p>
</div>
<div id="rammer">
<img class="test" alt="flare" src ="flare.jpg"/>
<img class="test" alt="giraffe" src ="gir.jpg"/>
<!-- annen type bildeskalering-->
</div>

<!-- COPYPASTE-->
<table cellspacing="0" class="table_ex">
<!-- Rad 1 -->
<tr>
<th>
Overskrift 1
</th>
<th>
Overskrift 2
</th>
</tr>
<!-- // SLUTT Rad 1 -->
<!-- Rad 2 -->
<tr>
<td>
Data 1
</td>
<td>
Data 2
</td>
</tr>
<!-- // SLUTT Rad 1 -->
<tr>
<td rowspan="2"> <!-- ett felt går over to rader-->
mer 1
</td>
<td>
mer 2
</td>
</tr>
<!-- // SLUTT Rad 2 -->
<tr>
<td>
mer mer
</td>
</tr>
</table>

<!--
Tabell med 2 horisontale celler slått sammen
-->

<table cellspacing="0" class="table_ex">
<!-- Rad 1 -->
<tr>
<th>
Overskrift 1
</th>

<th colspan="2"> <!--overskriften strekkes over to kolonner-->
Overskrift 2
</th>
</tr>
<!-- // SLUTT Rad 1 -->
<!-- Rad 2 -->
<tr>
<td>
Data 1
</td>
<td>
Data 2
</td>
<td>
Data 3
</td>
</tr>
<!-- // SLUTT Rad 2 -->
</table>
<p>
Tabell med to overskriftceller <br/>
slått sammen horisontalt (<b>colspan="2"</b>).
</p>
</div>
</div>
<!-- COPYPASTE-->
</body>
</html>
 
B

Belgian_Pilot

Guest
body
{
font-family: "Arial";
font-size: 100%;
}
h1
{
color: red;
font-family: "Courier New";
font-style: Italic;
font-weight: lighter;
text-align: center;
}

div#boks
{
margin-left: auto;
margin-right: auto;
margin-top: auto;
/*float: center;*/
background-color: blue;
text-align: center;
border: 1px solid #000000;
}
img
{
width: 50%;
height: 50%;
float: center;
}
p
{
color: black;
font-size: 12px;
font-family: Arial;
}
p.large
{
color: green;
font-size: 20px;
font-family: Impact;
}
p.bilde
{
margin: .2em;
font-size: 15px;
color: white;
font-weight: Lighter;
}
p.clear {
fl: left;
margin-left: 280px;
}
p.left { /* div.boks er satt til text align center, så må bruke denne for å venstrestille tekst i boksen*/
text-align: left;
font-size: 10px;
color: yellow;
}
p.right /* for å plassere teksten i forhold til rammen*/
{
width: 100px;
color: green;
margin-left: .5em;
margin-right: .5em;
}
div.rammer
{
float: left;
margin: .5em;
}
img.test /* undergruppe av bilder, disse er mindre enn standard*/
{width: 30%;
height: 45%;
margin: .5em;
}
img.float
{
float: center;
}
/*copypaste*/
/*plassering og linjestil */
table.table_ex {
clear: left;
float:center;
/*border-top: 1px solid #000; /*topplinje*/
/*border-right: 1px solid #000; /*høyre linjer*/
margin: 0em 1em 2em 1em; /* gir mellomrom ....topp høyre bunn venstre */
border-style:double; /*venstre og nede*/
}
/*rammer*/
table.table_ex th, table.table_ex td {
border-left: 1px solid #000; /* venstre linjer*/
border-bottom: 1px solid #000; /*nedre linjer*/
border-top: 1px solid #000;
border-right: 1px solid #000;
}
/*padding*/
table.table_ex th { /*header*/
background-color: #FF0000;
padding: .2em 1em; /* fyll ... bredde lengde */
}
/*align tekst*/
table.table_ex * {
text-align: center;
}
div#lframe
{
float:left;
width: 100px;
height: 200px;
padding: 10px;
margin-top: 1em; /*gjør at floaten inni diven ikke forkyves når det er tekst over diven*/
}
div#rframe
{
float:right;
width: 100px;
height: auto;
padding: 10px;
margin-top: 1em;
background-color: red;
margin-right: .5em;
}
div#venstreramma{ /* FAILS*/
margin: 0 auto 0 auto;
width: 200px;
height: 600px;
float: left;
padding: 5px;
background-color: #ababab;
border-top: 1px solid #000;
position: relative;
margin-left:auto;
margin-right: auto;
}
div#right
{
}

div#cc /* overlaps other divs*/
{
float: left;
width: 200px;
height: auto;
margin-right: auto;
position: relative;
margin-bottom: 0px;
margin-top: 10px;
text-align: center;
background-color: Olive;
font-family: Verdana;
}
 
B

Belgian_Pilot

Guest
Is that what you meant? Putting the cc div on the left, overlapping the rest?
 
W

wwjd_kilden

Guest
I must be going crazy, coz I can't find the wrap thing anymore

oh well...

the one marked fails simply stays on the bottom as a square
the last one will appear as a solid box (as inteded), but my left- floating div will then be gone
now I'm experimenting with a margin on the left side of my main document, but I'm not sure how to make something appear in the margin :p som atm I have a box underneath the place where my margin stops
 
B

Belgian_Pilot

Guest
I added the wrap div.

Wait - I think I dont get your question. You want the div marked 'fails' on the top left corner? Okay, no problem.

Then where do you want the div 'cc'?
 
B

Belgian_Pilot

Guest
I must be going crazy, coz I can't find the wrap thing anymore

oh well...

the one marked fails simply stays on the bottom as a square
the last one will appear as a solid box (as inteded), but my left- floating div will then be gone
now I'm experimenting with a margin on the left side of my main document, but I'm not sure how to make something appear in the margin :p som atm I have a box underneath the place where my margin stops
Yes, because thats what you prgrammed.

div#venstreramma{ /* FAILS*/
margin: 0 auto 0 auto;
width: 200px; Fixed width
height: 600px; Fixed height
float: left; It floats on the left side of my screen, so thats ok
padding: 5px;
background-color: #ababab;
border-top: 1px solid #000;
position: relative;
margin-left:auto;
margin-right: auto;
}


Can you specify what you want to see different?


 
W

wwjd_kilden

Guest
something like this

only that I want the left sidebar to stay all the way to the left, obviously :p


..and I'm also curious if there is a way to wrap text (ex a paragraph css formatting) to make sure the text don't hop around like it does here
 

Attachments