I have a bilingual page which is basically two columns with English text on the left and French on the right. The CSS for this is as follows:
div.ltext
{
margin: 10px 30px 0 60px;
line-height: 130%;
width:390px;
font-size:10pt;
font-weight:normal;
text-align:justify;
overflow:hidden;
float:left;
}
div.rtext
{
margin: 10px 60px 0 30px;
padding-left:30px;
line-height: 130%;
width:390px;
font-size:10pt;
font-weight:normal;
text-align:justify;
overflow:hidden;
}
At intervals the text is interspersed with an image (centered). The CSS of the images is as follows:
.pic
{
width:390px;
margin: 10px auto 10px auto;
}
The HTML looks like this:
<div class="ltext"><p>This grouping...</p></div>
<div class="rtext"><p><i>Cette plantation...</i> </p></div>
<div class="pic"><a onclick="loadImage('gdCG2013Jan05.jpg')" href="#4">
<imgwidth="390" border="0" src="gdCG2013Jan05tn.jpg"></img></a></div>
<div class="ltext"><p>Next,... </p></div>
<div class="rtext"><p><i>Suivant...</i> </p></div>
The problem is that whenever an image division (.pic) is inserted, the following text blocks are out of alignment (the French text on the right is approximately one line higher than the English. If I remove the image so that there are two consecutive blocks of bilingual text like this:
<div class="ltext"><p>This grouping...</p></div>
<div class="rtext"><p>Cette plantation...</p></div>
<! div class="pic"> removed
<div class="ltext"><p>Next...</p></div>
<div class="rtext"><p>Suivant deux...</p></div>
the alignment of the second set of blocks is correct. The problem is also corrected if I insert a dummy spacer division 1 pixel high between the image division and the following text divisions, thus:
.spacer {width:960px; height:1px; }
<div class="pic"> etc..</div>
<div class="spacer"> </div>
<div class="ltext"> etc... </div>
<div class="rtext"> etc. </div>
This last is a simple enough workaround but I would like to know what's going wrong here. (By the way, enclosing the following text blocks in a wrapper division doesn't solve the problem).
Create a container for the divs you dont want to move.
<div>
<div class="ltext"><p>This grouping...</p></div>
<div class="rtext"><p><i>Cette plantation...</i> </p></div>
</div>
<div class="pic"><a onclick="loadImage('gdCG2013Jan05.jpg')" href="#4">
<img width="390" border="0" src="gdCG2013Jan05tn.jpg"></img></a></div>
<div>
<div class="ltext"><p>Next,... </p></div>
<div class="rtext"><p><i>Suivant...</i> </p></div>
</div>
Your JSFiddle example does not have any image, but I suppose from what you've said the problem is that other elements appearing are moving the elements already existing.
Related
I have this issue: I have flexbox with 3 photos in the center of the screen.
under these photos, I have some text like mobile number etc.
When I add this text into this boxes, this text is defining the width of my box, and it's moving boxes and they are not in the center anymore.
Final result should be: The box width should be the same but text should break and be centered.
Here you can see size of one box
Here you can see size od the other box
Snippet:
.ikony {
padding-top: 60px;
display: inline-flex;
justify-content: center;
width: 100%;
font-weight: 600;
font-size: 16px;
color: #020E46;
text-align: center;
font-family: Open Sans,Arial,sans-serif;}
.column {
padding: 90px 70px 0px 70px;}
<div class="ikony">
<div class="column prvy">
<img src="img/mobil-icon.png" alt="iconka-mobil" width="100px" height="100px">
<div class="txtpod">
<p>+421 918 000 000</p>
</div>
</div>
<div class="column">
<img src="img/pin-icon.png" alt="ikona pinu" width="100px" height="100px">
<div class="txtpod">
<p>address 273/14, Svit</p>
</div>
</div>
<div class="column">
<img src="img/email.png" alt="ikona pinu" width="100px" height="100px">
<div class="txtpod">
<p>myemail#gmail.com</p>
</div>
</div>
</div>
Thanks for any advice
Add flex-grow: 0 and width: 33% to the flex items (.column) to prevent them to get wider.
However, if you have something like an email address in one of the containers that forces it to be wider than 33% because it contains no spaces and therefore can't break into several lines (like in your snippet example), you should use a small font that lets it fit into the 33% width.
I am trying to create two column boxes with clickable headers. I have everything setup and working but when I was testing I realized only half of the header was clickable. On the left column, the left half is clickable. On the right column, the right half is clickable. The 'a' tag applies to the entire header.
<section class="container">
<div class="row">
<div class="col-sm-6">
<div class="item-block">
<h3 class="block-header">#</h3>
<p>#</p>
</div>
<div class="item-block">
<h3 class="block-header">#</h3>
<p>#</p>
</div>
</div>
<div class="col-sm-6">
<div class="item-block">
<h3 class="block-header">#</h3>
<p>#</p>
</div>
<div class="item-block">
<h3 class="block-header">#</h3>
<p>#</p>
</div>
</div>
</div>
</section>
I have added a picture of the layout. At the top of each item-block is a block-header which is the blue bar. The red part is the part that is linked. The blue part does nothing.
css:
.item-block {
border: 2px solid #0026FF;
margin-left:20px;
margin-right:20px;
margin-bottom:20px;
border-radius: 6px;
font-size:1.2em;
}
.block-header {
text-align:center;
background:#0026FF;
padding:10px;
color:white;
margin-top:0px;
margin-bottom:10px;
border-radius: 3px 3px 0px 0px;
}
.item-block .block-header a {
color:white;
display:block;
}
Anyone know how to fix this so the entire header is clickable?
I figured out that the issue was another part of my page. Lower down on the page was a centered column that overlapped anything in the center of the page, making those halves not work properly. I changed the z-index of the dual columns to put it above the centered column and it works properly now.
I'm currently making a website using Zurb Foundation. (See pictures further down)
The way I've layed out my navigation is using the foundation grid as follows:
HTML
<div class="row">
<!-- Navigation -->
<nav class="top-bar">
<div class="five columns">
<div class="one columns"></div>
<div class="five columns menu-elements rightalign">
About
</div>
<div class="one columns">
<div class="split"></div>
</div>
<div class="five columns menu-elements rightalign">
Testimonials
</div>
</div>
<div class="two columns logo">
<img src="images/logo.png" alt="">
</div>
<div class="five columns">
<div class="five columns menu-elements leftalign">
Services
</div>
<div class="one columns">
<div class="split"></div>
</div>
<div class="five columns menu-elements leftalign">
Contact
</div>
<div class="one columns"></div>
</div>
CSS
.top-bar { font-family: 'bebas_neueregular'; display: flex; text-align:center; margin-bottom:0px;
.menu-elements{ color: white; display: block; font-size: 32px; font-weight: normal; height: 45px; ; margin: 60px 0 0 0;}
.menu-elements > a{ color: white; }
.menu-elements > a:hover{ color:#e87524;}
.logo{padding: 10px 0 0 0; text-align:center; margin:auto;}
.split{width: 3px;background: white;height: 28px; font-size: 32px; margin: 60px 0 0 0; text-align:center;}
.leftalign{text-align:left}
.rightalign{text-align:right;}
The problem I'm having is with the way my menu actually looks.
This is with the rightalign and leftalign classes included.
And this is without them included.
I want the menu to be:
1: With the Logo dead center, hence why I've made the navigation into separate div's.
2: The links should take up an even amount of space each, however the way I've coded this makes the Testimonials link take up way more space that the other links, as it is longer which makes it look out of place and closer to the Logo. I tried fixing this by using the text-align style to align both inner links closer to the logo. But it still doesn't look right.
I'm wondering if anyone can think of any other ways I can try? Perhaps making the actual font stretch the letters to meet the edge of the div's or a certain percentage of the div by assigning more space in between the letters? I'll take any advice at this point.
If this isn't necessarily a programming question please point me in the right direction. I am looking for answers as to what I could try in code or in external reading: ie: "Look this up it might help" or "Here try this code it should correct them".
Thanks for any advice!
In my html I get 'response' from controller. Number of lines in the response varies (max is 3).
What is the best way to 'reserve' 3 lines on my html page so the next div with 'SOMETHING' paragraph is not scrolled down by 'response' ?
<div class="row">
<p ng-bind-html="response"></p>
</div>
<div class="row">
<p>SOMETHING</p>
</div>
Using CSS, fix the height occupied by your 3 rows and use overflow to scroll within that fixed height div.
CSS Overflow might help you.
.row-fixed-height {
height: 150px;
overflow: scroll;
}
and in HTML:
<div class="row-fixed-height">
<p ng-bind-html="response"></p></div>
Since the height of the lines varies based on font and font size, I would use line breaks to "reserve" the three lines. If you were to use for instance a fixed height on the div or p, it might jump around on a different browser that uses a different font.
Live Demo:
#response {
background: red;
}
<div class="row">
<p id="response" ng-bind-html="response">
<br />
<br />
<br />
</p>
</div>
<div class="row">
<p>SOMETHING</p>
</div>
JSFiddle Version: https://jsfiddle.net/rspyho74/
As oori pointed you, this is is about CSS, not Angular. The easiest way to fix the height to 3 lines is using the em unit:
.row{
margin: 10px;
padding: 5px;
border: 1px solid #000;
border-radius: 5px;
}
p{
float: left;
margin: 0 5px;
padding: 5px;
border: 1px solid #000;
height: 3em;
}
<div class="row">
<p ng-bind-html="response"></p>
<p ng-bind-html="response">Line 1</p>
<p ng-bind-html="response">Line 1<br>Line 2</p>
<p ng-bind-html="response">Line 1<br>Line 2<br>Line 3</p>
<div style='clear: both;'></div>
</div>
<div class="row">
<p>SOMETHING</p>
<div style='clear: both;'></div>
</div>
As you can see, the paragraph keeps its height no matter how many lines there are. If you remove the height property you can see the difference.
I have the following code:
html
<div class="container">
<div class="float-left">
<img width="550" src="image.jpg" alt="" />
</div>
<div class="float-left">
<h1 class="new">Some long text here that should word wrap</h1>
</div>
<div class="clear"></div>
<div>
css
.container{
width:960px;
}
.float-left {
float:left
}
.clear{
clear:both;
}
h1.new{
font-family: RockwellMT-Light;
font-size: 28px;
line-height: 31px;
}
I want the divs to act like 2 columns One will be the image and the second one should be text that can go down as much as it takes.
Since float left does not have a fixed width the problem is that the whole element h1 is jumping on the new line and the text does not goes on the next line.
I don't want to give fixed widths to the floating divs.
How can I prevent this?
You could remove class="float-left" from the second <div> and it would work.
you can try smth like this:
<div class="container">
<div class="something">something</div>
<div class="nextthing float-left">
<h1 class="new">Some long text here that should word wrap</h1>
</div>
<div class="clear"></div>
<div>
.container {
position: relative;
}
.something {
position: absolute;
}
.nextthing {
text-indent: size_of_.something;
}
Or change float:left, to display:inline-block;