- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试在我的 webapp 元素中使用侧边栏,因为我有如下所示的 sidebar.jsp:
.social {
width: 100px;
height: 220px;
left: 0px;
}
.social li a {
display: block;
background: #222;
font: normal normal normal
16px/20px
'FontAwesome', 'Source Sans Pro', Helvetica, Arial, sans-serif;
color: #fff;
-webkit-font-smoothing: antialiased;;
text-decoration: none;
text-align: center;
transition: background .5s ease .300ms
}
.social li{
list-style: none;
}
.social li:first-child a:hover { background: #3b5998 }
.social li:nth-child(2) a:hover { background: #00acee }
.social li:nth-child(3) a:hover { background: #ea4c89 }
.social li:nth-child(4) a:hover { background: #dd4b39 }
.social li:first-child a { border-radius: 0 5px 0 0 }
.social li:last-child a { border-radius: 0 0 5px 0 }
.social li a span {
width: 250px;
float: left;
text-align: left;
background: #222;
color: #fff;
margin: -25px 74px;
padding: 8px;
transform-origin: 0;
visibility: hidden;
opacity: 0;
transform: rotateY(45deg);
border-radius: 5px;
transition: all .5s ease .300ms;
overflow: auto;
}
.social li span:after {
content: '';
display: block;
width: 0;
height: 0;
position: absolute;
left: -20px;
top: 7px;
border-left: 10px solid transparent;
border-right: 10px solid #222;
border-bottom: 10px solid transparent;
border-top: 10px solid transparent;
}
.social li a:hover span {
visibility: visible;
opacity: 1;
transform: rotateY(0)
}
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro' rel='stylesheet' type='text/css'>
<ul class='social'>
<li>
<a href="#"> First
<span>This is a big spawn that will break my app</span>
</a>
</li>
<li>
<a href="#"> Second
<span>This is a big spawn that will break my app This is a big spawn that will break my appThis is a big spawn that will break my appThis is a big spawn that will break my app</span>
</a>
</li>
<li>
<a href="#"> Third
<span>This is a big spawn that will break my app</span>
</a>
</li>
</ul>
它工作正常,但是,正如您所看到的,“第二个”元素有一个非常大的产卵,所以这使得我的“第三个”元素之前有这么多空间。
有什么方法可以使 spawn 的大小不影响我的列表大小?我的意思是,我希望所有元素都具有相同的大小,无论 spawn 有多大。
最佳答案
你需要绝对定位你的 span,这样它就可以脱离页面流(不占用任何空间)——我在下面的 css 中添加了注释
.social {
width: 100px;
height: 220px;
left: 0px;
}
.social li a {
width:100%;
display: block;
background: #222;
font: normal normal normal 16px/20px 'FontAwesome', 'Source Sans Pro', Helvetica, Arial, sans-serif;
color: #fff;
-webkit-font-smoothing: antialiased;
text-decoration: none;
text-align: center;
transition: background .5s ease .300ms;
position:relative; /* add this to make span position relative to anchor */
}
.social li {
list-style: none;
}
.social li:first-child a:hover {
background: #3b5998
}
.social li:nth-child(2) a:hover {
background: #00acee
}
.social li:nth-child(3) a:hover {
background: #ea4c89
}
.social li:nth-child(4) a:hover {
background: #dd4b39
}
.social li:first-child a {
border-radius: 0 5px 0 0
}
.social li:last-child a {
border-radius: 0 0 5px 0
}
.social li a span {
width: 250px;
text-align: left;
background: #222;
color: #fff;
padding: 8px;
transform-origin: 0;
visibility: hidden;
opacity: 0;
transform: translateY(-50%) rotateY(45deg); /* I added this translate just to vertically center it along with top 50% */
border-radius: 5px;
transition: all .5s ease .300ms;
overflow: auto;
position:absolute; /* add the following - play with top and left to adjust the position, I have removed float left and margin from here */
left: calc(100% + 10px); /* the 10px is the gap */
top:50%;
}
.social li span:after {
content: '';
display: block;
width: 0;
height: 0;
position: absolute;
left: -20px;
top: 7px;
border-left: 10px solid transparent;
border-right: 10px solid #222;
border-bottom: 10px solid transparent;
border-top: 10px solid transparent;
}
.social li a:hover span {
visibility: visible;
opacity: 1;
transform: rotateY(0) translateY(-50%); /* translate needs to go here too */
}
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro' rel='stylesheet' type='text/css'>
<ul class='social'>
<li>
<a href="#"> First
<span>This is a big spawn that will break my app</span>
</a>
</li>
<li>
<a href="#"> Second
<span>This is a big spawn that will break my app This is a big spawn that will break my appThis is a big spawn that will break my appThis is a big spawn that will break my app</span>
</a>
</li>
<li>
<a href="#"> Third
<span>This is a big spawn that will break my app</span>
</a>
</li>
</ul>
关于html - 如何避免跨度大小影响父级的 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44153701/
这就是我现在正在做的事情。我在设计中使用 LESS CSS。我需要在指定输入之间放置 2 个跨度。所有元素的宽度都应为 100%。跨度应始终为 20px 宽度输入宽度可以根据屏幕宽度进行更改。谁能帮帮
我有一个包含文本和输入字段的跨度。我想知道是否可以让文本左对齐,输入字段右对齐。 NAME: .textBox{ display:inline-block; width:450px
我有这个按钮,我想让它在我点击“选择”时调用方法,在我点击“更改”时调用另一个方法: Select Change 我尝试输入 (click)="method()",但没有成功。我很
我正在开发聊天应用程序 (cordova),当我要在无法输入的表情符号后输入文本时,我在这段代码中遇到了问题 https://output.jsbin.com/radaref This i
很抱歉,如果这是一个非常愚蠢的问题,但我是一名开发人员,目前我的设计技能很少,我在个人网站上工作并且遇到了一个小问题。 我有一个带 ul 的顶部导航和 li元素。这些元素包含链接 . 跨度仅在链接悬
fiddle :https://jsfiddle.net/burz4g8s/4/ 我的 HTML 包含多行双按钮对。服务器端应用程序在 JSP 循环中输出按钮,所以我无法控制各个按钮——我不能使用 d
TextView.setLetterSpacing允许设置字母间距/字符间距。 有没有对应的CharacterStyle / span class允许在 TextView? 中的文本子集上设置字母间距
如何使洋红色矩形比红色矩形短 6 倍? GridLayout { id: gridLayout anchors.fill: parent flo
我最近开始使用 Twitter Bootstrap,但我似乎无法理解 span 的作用以及为什么会有不同的编号 span,例如 span4、span12?什么是偏移量以及它们何时使用? (有时与跨度一
我正在尝试构建一个 jQuery 函数来计算跨度中的总数 var sumnormaltotal = 0; $('span[id^="normaloffertotalspan"]').each(func
我想知道haskell如何评估以下表达式。 span (`elem` ['A'..'Z']) "BOBsidneyMORGANeddy" 结果是 ("BOB","sidneyMORGANeddy")
我有三个词,我想在第一个空格之后的内容周围添加一个跨度,所以 hello world 变成: hello world 和: hello world again 变成: hello world agai
我正在寻找纯 CSS 解决以下问题的方法。 考虑以下 HTML: Some text Some text 两者都是 正在显示元素 inline-block .如何在第二个 的左侧
如何将 Span 放置在其容器的底部? 我目前拥有的:http://jsfiddle.net/wRbax/2/ 我希望 .box 始终位于 .td 的底部 CSS .td { vertical
我试图在 li 中 float 两个 span。左跨度将有我的标签,在右跨度内我将构建一个具有嵌套跨度的图形。我有基本结构,但 chrome 将数字放在左侧跨度的末尾。我该如何解决这个问题? HTML
我有一个像这样的 JavaScript 变量: var text = "A businessman should be able to manage his business matters"; 我想
一些内容可编辑的框与其他框重叠,因此并非所有框都是可编辑的。我想保留与跨度位置中心对齐的文本,如下所示。我如何实现这一点? span { margin: auto; text-alig
我正在使用 WYSIWYG (InnovaEditor) 来编辑我网站上的内容,它适用于 Chrome、IE,主要适用于 Firefox,但 FF 有一个稍微令人讨厌的问题。我将 span 标签插入到
这是我的 html: Settings Export Import 和CSS: span.button { float:right; margin-righ
这里是问题所在:http://jsfiddle.net/STG22/3/ 我希望 span 不会分成两个不同的行(就像上面示例中的第三行一样)。我该怎么做? CSS: span { backg
我是一名优秀的程序员,十分优秀!