菜单:第一个孩子和:悬停

时间:2017-07-21 09:40:17

标签: css css3 menu

我有水平菜单,两侧都有border-radius。当每个元素处于活动状态时,它具有background-color。我使用:first-child在第一个元素上设置了背景,但我对:hover有疑问。我需要在左上角和左下角的第一个元素悬停半径。此时:hover是基本矩形。

这是代码

ul.nav li.current-menu-item:first-child a, ul.nav li.current_page_item:first-child a {
color: #ffffff;
background: url(../gfx/menu_hover.gif) left top repeat-x;
border-top-left-radius:7px;
border-bottom-left-radius:7px;
}

2 个答案:

答案 0 :(得分:0)

您可以按照:将鼠标悬停在菜单上以获得效果,如下所示。

ul.nav li.current-menu-item:first-child a:hover, 
ul.nav li.current_page_item:first-child a:hover

答案 1 :(得分:0)

正如您所说,您的代码应该可以正常工作,但还有一个问题可能是public class MainActivity extends AppCompatActivity { Integer[] images = {R.drawable.Harvey, R.drawable.Litt,R.drawable.Mike,R.drawable.harvey, R.drawable.mark_wahlberg , R.drawable.oliver}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GridView gridView = (GridView)findViewById(R.id.grid1); gridView.setAdapter(new CustomGridAdapter(this, images)); gridView.setAdapter(adapter); } } // Here is your custom Adapter public class CustomGridAdapter extends BaseAdapter { private Activity mContext; // Keep all Images in array public Integer[] mThumbIds; // Constructor public CustomGridAdapter(MainActivity mainActivity, Integer[] items) { this.mContext = mainActivity; this.mThumbIds = items; } @Override public int getCount() { return mThumbIds.length; } @Override public Object getItem(int position) { return mThumbIds[position]; } @Override public long getItemId(int position) { return 0; } @Override public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView = new ImageView(mContext); imageView.setImageResource(mThumbIds[position]); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setLayoutParams(new GridView.LayoutParams(70, 70)); return imageView; } } } 标记可能从其父级继承:

因此,您需要在a规则中使用!important ...

border-radius