简体   繁体   English

对齐不相关的 div

[英]Aligning divs that are not related

http://codepen.io/anon/pen/Gxbfu <-- Here is the bits of the site I'm trying to align. http://codepen.io/anon/pen/Gxbfu <-- 这是我试图对齐的网站的部分内容。

What I'm trying to achieve, is Onyx Design to align with the right side of the navbar, or navbar to scale to the end of "Onyx Design".我想要实现的是 Onyx Design 与导航栏的右侧对齐,或者导航栏缩放到“Onyx Design”的末尾。

The text is not related to the navbar, unless uncle is a term used for div relations.文本与导航栏无关,除非叔叔是用于 div 关系的术语。

jQuery/JS IS an option, as I will have that on the site when I get to making it functional. jQuery/JS 是一个选项,因为当我开始使用它时,我会在网站上使用它。

Here's what I want to make it look like http://puu.sh/5cq82.png这是我想让它看起来像http://puu.sh/5cq82.png

Divs that matter;重要的 Div;

.titling contains the header, and has the border-top and border-bottom .bottomheader contains .navbar (the white strip with icons on) and the heart button. .titling包含标题,并有border-topborder-bottom .bottomheader包含.navbar (带有图标的白色条带)和心形按钮。

I just used this piece of code:我刚刚使用了这段代码:

h1
  max-width 300px
  width 300px
  text-align right

Might not be the best one, but suits your needs.可能不是最好的,但适合您的需求。

Fiddle: http://codepen.io/anon/pen/phAHc小提琴: http : //codepen.io/anon/pen/phAHc

If you dont know how long the navbar will be you can use some javascript (with jquery) to set the width:如果您不知道导航栏有多长,您可以使用一些 javascript(使用 jquery)来设置宽度:

$(function(){

   var h1 = $('.titling>h1');
   var navbar = $('.navbar');      
   h1.css({width: (navbar.width() + 'px'), 'text-align':'right'});  

});

Forked: http://codepen.io/anon/pen/jxrDF分叉: http : //codepen.io/anon/pen/jxrDF

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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